aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/DocBook/kernel-api.tmpl2
-rw-r--r--arch/arm/mm/pgd.c6
-rw-r--r--arch/m68k/kernel/entry.S4
-rw-r--r--arch/m68knommu/defconfig112
-rw-r--r--arch/m68knommu/kernel/syscalltable.S4
-rw-r--r--arch/m68knommu/platform/68328/timers.c10
-rw-r--r--arch/powerpc/boot/cuboot-bamboo.c1
-rw-r--r--arch/powerpc/boot/cuboot-ebony.c1
-rw-r--r--arch/powerpc/boot/cuboot-katmai.c1
-rw-r--r--arch/powerpc/boot/cuboot-taishan.c2
-rw-r--r--arch/powerpc/boot/cuboot-warp.c1
-rw-r--r--arch/powerpc/boot/dts/haleakala.dts2
-rw-r--r--arch/powerpc/boot/dts/katmai.dts58
-rw-r--r--arch/powerpc/oprofile/op_model_cell.c2
-rw-r--r--arch/powerpc/platforms/52xx/mpc52xx_common.c1
-rw-r--r--arch/powerpc/platforms/cell/iommu.c151
-rw-r--r--arch/powerpc/platforms/cell/setup.c7
-rw-r--r--arch/powerpc/platforms/cell/spu_base.c16
-rw-r--r--arch/powerpc/platforms/cell/spufs/context.c7
-rw-r--r--arch/powerpc/platforms/cell/spufs/file.c12
-rw-r--r--arch/powerpc/platforms/cell/spufs/sched.c2
-rw-r--r--arch/powerpc/platforms/cell/spufs/sputrace.c7
-rw-r--r--arch/powerpc/platforms/cell/spufs/switch.c6
-rw-r--r--arch/powerpc/platforms/celleb/beat.h3
-rw-r--r--arch/x86/mm/pageattr.c21
-rw-r--r--block/blk-barrier.c9
-rw-r--r--block/blk-core.c7
-rw-r--r--block/blk-map.c27
-rw-r--r--block/blk-merge.c2
-rw-r--r--block/blk-settings.c22
-rw-r--r--block/blk-tag.c2
-rw-r--r--block/blk.h2
-rw-r--r--block/bsg.c8
-rw-r--r--block/genhd.c10
-rw-r--r--block/scsi_ioctl.c4
-rw-r--r--drivers/acorn/char/defkeymap-l7200.c68
-rw-r--r--drivers/ata/libata-scsi.c9
-rw-r--r--drivers/base/transport_class.c4
-rw-r--r--drivers/block/cciss.c256
-rw-r--r--drivers/block/cciss_scsi.c10
-rw-r--r--drivers/cdrom/cdrom.c4
-rw-r--r--drivers/char/defkeymap.c_shipped68
-rw-r--r--drivers/char/xilinx_hwicap/buffer_icap.c80
-rw-r--r--drivers/char/xilinx_hwicap/fifo_icap.c60
-rw-r--r--drivers/char/xilinx_hwicap/xilinx_hwicap.c138
-rw-r--r--drivers/char/xilinx_hwicap/xilinx_hwicap.h24
-rw-r--r--drivers/message/fusion/mptbase.c25
-rw-r--r--drivers/message/fusion/mptscsih.c14
-rw-r--r--drivers/net/fec.c8
-rw-r--r--drivers/pci/rom.c3
-rw-r--r--drivers/rapidio/rio-driver.c8
-rw-r--r--drivers/s390/char/defkeymap.c4
-rw-r--r--drivers/scsi/scsi_scan.c3
-rw-r--r--drivers/usb/core/usb.c6
-rw-r--r--fs/buffer.c3
-rw-r--r--fs/cifs/CHANGES4
-rw-r--r--fs/cifs/README2
-rw-r--r--fs/cifs/cifs_debug.c17
-rw-r--r--fs/cifs/cifs_debug.h9
-rw-r--r--fs/cifs/cifs_dfs_ref.c2
-rw-r--r--fs/cifs/cifs_spnego.c2
-rw-r--r--fs/cifs/cifs_unicode.c4
-rw-r--r--fs/cifs/cifs_unicode.h9
-rw-r--r--fs/cifs/cifsacl.c57
-rw-r--r--fs/cifs/cifsfs.c15
-rw-r--r--fs/cifs/cifsglob.h2
-rw-r--r--fs/cifs/cifsproto.h22
-rw-r--r--fs/cifs/cifssmb.c218
-rw-r--r--fs/cifs/connect.c50
-rw-r--r--fs/cifs/dir.c20
-rw-r--r--fs/cifs/dns_resolve.h2
-rw-r--r--fs/cifs/fcntl.c6
-rw-r--r--fs/cifs/file.c33
-rw-r--r--fs/cifs/inode.c399
-rw-r--r--fs/cifs/ioctl.c2
-rw-r--r--fs/cifs/md4.c4
-rw-r--r--fs/cifs/md5.c9
-rw-r--r--fs/cifs/misc.c14
-rw-r--r--fs/cifs/netmisc.c23
-rw-r--r--fs/cifs/readdir.c54
-rw-r--r--fs/cifs/sess.c4
-rw-r--r--fs/cifs/smbdes.c22
-rw-r--r--fs/cifs/transport.c11
-rw-r--r--fs/cifs/xattr.c9
-rw-r--r--fs/exec.c10
-rw-r--r--fs/jbd/transaction.c17
-rw-r--r--fs/mpage.c11
-rw-r--r--fs/proc/proc_misc.c3
-rw-r--r--fs/splice.c12
-rw-r--r--include/asm-m68k/unistd.h6
-rw-r--r--include/asm-m68knommu/machdep.h2
-rw-r--r--include/asm-m68knommu/unistd.h6
-rw-r--r--include/asm-powerpc/reg.h3
-rw-r--r--include/asm-x86/pgtable_32.h4
-rw-r--r--include/asm-x86/pgtable_64.h6
-rw-r--r--include/linux/blkdev.h4
-rw-r--r--include/linux/genhd.h5
-rw-r--r--include/linux/mm_types.h5
-rw-r--r--include/linux/slub_def.h4
-rw-r--r--include/linux/usb.h9
-rw-r--r--kernel/exit.c96
-rw-r--r--kernel/power/process.c29
-rw-r--r--kernel/signal.c16
-rw-r--r--mm/slub.c204
-rw-r--r--mm/truncate.c3
105 files changed, 1350 insertions, 1457 deletions
diff --git a/Documentation/DocBook/kernel-api.tmpl b/Documentation/DocBook/kernel-api.tmpl
index f31601e8bd89..dc0f30c3e571 100644
--- a/Documentation/DocBook/kernel-api.tmpl
+++ b/Documentation/DocBook/kernel-api.tmpl
@@ -361,12 +361,14 @@ X!Edrivers/pnp/system.c
361 <chapter id="blkdev"> 361 <chapter id="blkdev">
362 <title>Block Devices</title> 362 <title>Block Devices</title>
363!Eblock/blk-core.c 363!Eblock/blk-core.c
364!Iblock/blk-core.c
364!Eblock/blk-map.c 365!Eblock/blk-map.c
365!Iblock/blk-sysfs.c 366!Iblock/blk-sysfs.c
366!Eblock/blk-settings.c 367!Eblock/blk-settings.c
367!Eblock/blk-exec.c 368!Eblock/blk-exec.c
368!Eblock/blk-barrier.c 369!Eblock/blk-barrier.c
369!Eblock/blk-tag.c 370!Eblock/blk-tag.c
371!Iblock/blk-tag.c
370 </chapter> 372 </chapter>
371 373
372 <chapter id="chrdev"> 374 <chapter id="chrdev">
diff --git a/arch/arm/mm/pgd.c b/arch/arm/mm/pgd.c
index 500c9610ab30..e0f19ab91163 100644
--- a/arch/arm/mm/pgd.c
+++ b/arch/arm/mm/pgd.c
@@ -75,7 +75,7 @@ no_pgd:
75void free_pgd_slow(struct mm_struct *mm, pgd_t *pgd) 75void free_pgd_slow(struct mm_struct *mm, pgd_t *pgd)
76{ 76{
77 pmd_t *pmd; 77 pmd_t *pmd;
78 struct page *pte; 78 pgtable_t pte;
79 79
80 if (!pgd) 80 if (!pgd)
81 return; 81 return;
@@ -90,10 +90,8 @@ void free_pgd_slow(struct mm_struct *mm, pgd_t *pgd)
90 goto free; 90 goto free;
91 } 91 }
92 92
93 pte = pmd_page(*pmd); 93 pte = pmd_pgtable(*pmd);
94 pmd_clear(pmd); 94 pmd_clear(pmd);
95 dec_zone_page_state(virt_to_page((unsigned long *)pgd), NR_PAGETABLE);
96 pte_lock_deinit(pte);
97 pte_free(mm, pte); 95 pte_free(mm, pte);
98 pmd_free(mm, pmd); 96 pmd_free(mm, pmd);
99free: 97free:
diff --git a/arch/m68k/kernel/entry.S b/arch/m68k/kernel/entry.S
index 6dfa3b3c0e2a..18a9c5f4b00d 100644
--- a/arch/m68k/kernel/entry.S
+++ b/arch/m68k/kernel/entry.S
@@ -742,7 +742,9 @@ sys_call_table:
742 .long sys_epoll_pwait /* 315 */ 742 .long sys_epoll_pwait /* 315 */
743 .long sys_utimensat 743 .long sys_utimensat
744 .long sys_signalfd 744 .long sys_signalfd
745 .long sys_ni_syscall 745 .long sys_timerfd_create
746 .long sys_eventfd 746 .long sys_eventfd
747 .long sys_fallocate /* 320 */ 747 .long sys_fallocate /* 320 */
748 .long sys_timerfd_settime
749 .long sys_timerfd_gettime
748 750
diff --git a/arch/m68knommu/defconfig b/arch/m68knommu/defconfig
index 648113075f97..670b0a99cfa0 100644
--- a/arch/m68knommu/defconfig
+++ b/arch/m68knommu/defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.23 3# Linux kernel version: 2.6.25-rc3
4# Thu Oct 18 13:17:38 2007 4# Mon Feb 25 15:03:00 2008
5# 5#
6CONFIG_M68K=y 6CONFIG_M68K=y
7# CONFIG_MMU is not set 7# CONFIG_MMU is not set
@@ -15,8 +15,10 @@ CONFIG_GENERIC_FIND_NEXT_BIT=y
15CONFIG_GENERIC_HWEIGHT=y 15CONFIG_GENERIC_HWEIGHT=y
16CONFIG_GENERIC_HARDIRQS=y 16CONFIG_GENERIC_HARDIRQS=y
17CONFIG_GENERIC_CALIBRATE_DELAY=y 17CONFIG_GENERIC_CALIBRATE_DELAY=y
18CONFIG_GENERIC_TIME=y
18CONFIG_TIME_LOW_RES=y 19CONFIG_TIME_LOW_RES=y
19CONFIG_NO_IOPORT=y 20CONFIG_NO_IOPORT=y
21CONFIG_ARCH_SUPPORTS_AOUT=y
20CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 22CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
21 23
22# 24#
@@ -31,12 +33,14 @@ CONFIG_LOCALVERSION_AUTO=y
31# CONFIG_POSIX_MQUEUE is not set 33# CONFIG_POSIX_MQUEUE is not set
32# CONFIG_BSD_PROCESS_ACCT is not set 34# CONFIG_BSD_PROCESS_ACCT is not set
33# CONFIG_TASKSTATS is not set 35# CONFIG_TASKSTATS is not set
34# CONFIG_USER_NS is not set
35# CONFIG_AUDIT is not set 36# CONFIG_AUDIT is not set
36# CONFIG_IKCONFIG is not set 37# CONFIG_IKCONFIG is not set
37CONFIG_LOG_BUF_SHIFT=14 38CONFIG_LOG_BUF_SHIFT=14
39# CONFIG_CGROUPS is not set
40# CONFIG_GROUP_SCHED is not set
38# CONFIG_SYSFS_DEPRECATED is not set 41# CONFIG_SYSFS_DEPRECATED is not set
39# CONFIG_RELAY is not set 42# CONFIG_RELAY is not set
43# CONFIG_NAMESPACES is not set
40# CONFIG_BLK_DEV_INITRD is not set 44# CONFIG_BLK_DEV_INITRD is not set
41# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 45# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
42CONFIG_SYSCTL=y 46CONFIG_SYSCTL=y
@@ -48,15 +52,22 @@ CONFIG_SYSCTL_SYSCALL=y
48CONFIG_PRINTK=y 52CONFIG_PRINTK=y
49CONFIG_BUG=y 53CONFIG_BUG=y
50CONFIG_ELF_CORE=y 54CONFIG_ELF_CORE=y
55CONFIG_COMPAT_BRK=y
51CONFIG_BASE_FULL=y 56CONFIG_BASE_FULL=y
52# CONFIG_FUTEX is not set 57# CONFIG_FUTEX is not set
53# CONFIG_EPOLL is not set 58# CONFIG_EPOLL is not set
54# CONFIG_SIGNALFD is not set 59# CONFIG_SIGNALFD is not set
60# CONFIG_TIMERFD is not set
55# CONFIG_EVENTFD is not set 61# CONFIG_EVENTFD is not set
56# CONFIG_VM_EVENT_COUNTERS is not set 62# CONFIG_VM_EVENT_COUNTERS is not set
57CONFIG_SLAB=y 63CONFIG_SLAB=y
58# CONFIG_SLUB is not set 64# CONFIG_SLUB is not set
59# CONFIG_SLOB is not set 65# CONFIG_SLOB is not set
66# CONFIG_PROFILING is not set
67# CONFIG_MARKERS is not set
68# CONFIG_HAVE_OPROFILE is not set
69# CONFIG_HAVE_KPROBES is not set
70CONFIG_SLABINFO=y
60CONFIG_TINY_SHMEM=y 71CONFIG_TINY_SHMEM=y
61CONFIG_BASE_SMALL=0 72CONFIG_BASE_SMALL=0
62CONFIG_MODULES=y 73CONFIG_MODULES=y
@@ -83,6 +94,8 @@ CONFIG_IOSCHED_NOOP=y
83# CONFIG_DEFAULT_CFQ is not set 94# CONFIG_DEFAULT_CFQ is not set
84CONFIG_DEFAULT_NOOP=y 95CONFIG_DEFAULT_NOOP=y
85CONFIG_DEFAULT_IOSCHED="noop" 96CONFIG_DEFAULT_IOSCHED="noop"
97CONFIG_CLASSIC_RCU=y
98# CONFIG_PREEMPT_RCU is not set
86 99
87# 100#
88# Processor type and features 101# Processor type and features
@@ -121,6 +134,7 @@ CONFIG_M5272C3=y
121# CONFIG_MOD5272 is not set 134# CONFIG_MOD5272 is not set
122CONFIG_FREESCALE=y 135CONFIG_FREESCALE=y
123CONFIG_4KSTACKS=y 136CONFIG_4KSTACKS=y
137CONFIG_HZ=100
124 138
125# 139#
126# RAM configuration 140# RAM configuration
@@ -147,6 +161,7 @@ CONFIG_FLATMEM_MANUAL=y
147CONFIG_FLATMEM=y 161CONFIG_FLATMEM=y
148CONFIG_FLAT_NODE_MEM_MAP=y 162CONFIG_FLAT_NODE_MEM_MAP=y
149# CONFIG_SPARSEMEM_STATIC is not set 163# CONFIG_SPARSEMEM_STATIC is not set
164# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
150CONFIG_SPLIT_PTLOCK_CPUS=4 165CONFIG_SPLIT_PTLOCK_CPUS=4
151# CONFIG_RESOURCES_64BIT is not set 166# CONFIG_RESOURCES_64BIT is not set
152CONFIG_ZONE_DMA_FLAG=1 167CONFIG_ZONE_DMA_FLAG=1
@@ -159,10 +174,6 @@ CONFIG_VIRT_TO_BUS=y
159# CONFIG_ARCH_SUPPORTS_MSI is not set 174# CONFIG_ARCH_SUPPORTS_MSI is not set
160 175
161# 176#
162# PCCARD (PCMCIA/CardBus) support
163#
164
165#
166# Executable file formats 177# Executable file formats
167# 178#
168CONFIG_BINFMT_FLAT=y 179CONFIG_BINFMT_FLAT=y
@@ -205,6 +216,7 @@ CONFIG_IP_FIB_HASH=y
205# CONFIG_INET_XFRM_MODE_TRANSPORT is not set 216# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
206# CONFIG_INET_XFRM_MODE_TUNNEL is not set 217# CONFIG_INET_XFRM_MODE_TUNNEL is not set
207# CONFIG_INET_XFRM_MODE_BEET is not set 218# CONFIG_INET_XFRM_MODE_BEET is not set
219# CONFIG_INET_LRO is not set
208# CONFIG_INET_DIAG is not set 220# CONFIG_INET_DIAG is not set
209# CONFIG_TCP_CONG_ADVANCED is not set 221# CONFIG_TCP_CONG_ADVANCED is not set
210CONFIG_TCP_CONG_CUBIC=y 222CONFIG_TCP_CONG_CUBIC=y
@@ -229,10 +241,6 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
229# CONFIG_LAPB is not set 241# CONFIG_LAPB is not set
230# CONFIG_ECONET is not set 242# CONFIG_ECONET is not set
231# CONFIG_WAN_ROUTER is not set 243# CONFIG_WAN_ROUTER is not set
232
233#
234# QoS and/or fair queueing
235#
236# CONFIG_NET_SCHED is not set 244# CONFIG_NET_SCHED is not set
237 245
238# 246#
@@ -240,6 +248,7 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
240# 248#
241# CONFIG_NET_PKTGEN is not set 249# CONFIG_NET_PKTGEN is not set
242# CONFIG_HAMRADIO is not set 250# CONFIG_HAMRADIO is not set
251# CONFIG_CAN is not set
243# CONFIG_IRDA is not set 252# CONFIG_IRDA is not set
244# CONFIG_BT is not set 253# CONFIG_BT is not set
245# CONFIG_AF_RXRPC is not set 254# CONFIG_AF_RXRPC is not set
@@ -283,6 +292,7 @@ CONFIG_MTD_BLOCK=y
283# CONFIG_INFTL is not set 292# CONFIG_INFTL is not set
284# CONFIG_RFD_FTL is not set 293# CONFIG_RFD_FTL is not set
285# CONFIG_SSFDC is not set 294# CONFIG_SSFDC is not set
295# CONFIG_MTD_OOPS is not set
286 296
287# 297#
288# RAM/ROM/Flash chip drivers 298# RAM/ROM/Flash chip drivers
@@ -339,10 +349,11 @@ CONFIG_BLK_DEV=y
339CONFIG_BLK_DEV_RAM=y 349CONFIG_BLK_DEV_RAM=y
340CONFIG_BLK_DEV_RAM_COUNT=16 350CONFIG_BLK_DEV_RAM_COUNT=16
341CONFIG_BLK_DEV_RAM_SIZE=4096 351CONFIG_BLK_DEV_RAM_SIZE=4096
342CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024 352# CONFIG_BLK_DEV_XIP is not set
343# CONFIG_CDROM_PKTCDVD is not set 353# CONFIG_CDROM_PKTCDVD is not set
344# CONFIG_ATA_OVER_ETH is not set 354# CONFIG_ATA_OVER_ETH is not set
345# CONFIG_MISC_DEVICES is not set 355# CONFIG_MISC_DEVICES is not set
356CONFIG_HAVE_IDE=y
346# CONFIG_IDE is not set 357# CONFIG_IDE is not set
347 358
348# 359#
@@ -360,9 +371,15 @@ CONFIG_NETDEVICES=y
360# CONFIG_MACVLAN is not set 371# CONFIG_MACVLAN is not set
361# CONFIG_EQUALIZER is not set 372# CONFIG_EQUALIZER is not set
362# CONFIG_TUN is not set 373# CONFIG_TUN is not set
374# CONFIG_VETH is not set
363# CONFIG_PHYLIB is not set 375# CONFIG_PHYLIB is not set
364CONFIG_NET_ETHERNET=y 376CONFIG_NET_ETHERNET=y
365# CONFIG_MII is not set 377# CONFIG_MII is not set
378# CONFIG_IBM_NEW_EMAC_ZMII is not set
379# CONFIG_IBM_NEW_EMAC_RGMII is not set
380# CONFIG_IBM_NEW_EMAC_TAH is not set
381# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
382# CONFIG_B44 is not set
366CONFIG_FEC=y 383CONFIG_FEC=y
367# CONFIG_FEC2 is not set 384# CONFIG_FEC2 is not set
368# CONFIG_NETDEV_1000 is not set 385# CONFIG_NETDEV_1000 is not set
@@ -377,7 +394,7 @@ CONFIG_FEC=y
377CONFIG_PPP=y 394CONFIG_PPP=y
378# CONFIG_PPP_MULTILINK is not set 395# CONFIG_PPP_MULTILINK is not set
379# CONFIG_PPP_FILTER is not set 396# CONFIG_PPP_FILTER is not set
380# CONFIG_PPP_ASYNC is not set 397CONFIG_PPP_ASYNC=y
381# CONFIG_PPP_SYNC_TTY is not set 398# CONFIG_PPP_SYNC_TTY is not set
382# CONFIG_PPP_DEFLATE is not set 399# CONFIG_PPP_DEFLATE is not set
383# CONFIG_PPP_BSDCOMP is not set 400# CONFIG_PPP_BSDCOMP is not set
@@ -386,7 +403,6 @@ CONFIG_PPP=y
386# CONFIG_PPPOL2TP is not set 403# CONFIG_PPPOL2TP is not set
387# CONFIG_SLIP is not set 404# CONFIG_SLIP is not set
388CONFIG_SLHC=y 405CONFIG_SLHC=y
389# CONFIG_SHAPER is not set
390# CONFIG_NETCONSOLE is not set 406# CONFIG_NETCONSOLE is not set
391# CONFIG_NETPOLL is not set 407# CONFIG_NETPOLL is not set
392# CONFIG_NET_POLL_CONTROLLER is not set 408# CONFIG_NET_POLL_CONTROLLER is not set
@@ -418,12 +434,16 @@ CONFIG_SLHC=y
418# 434#
419# Non-8250 serial port support 435# Non-8250 serial port support
420# 436#
421CONFIG_SERIAL_COLDFIRE=y 437CONFIG_SERIAL_CORE=y
438CONFIG_SERIAL_CORE_CONSOLE=y
439# CONFIG_SERIAL_COLDFIRE is not set
440CONFIG_SERIAL_MCF=y
441CONFIG_SERIAL_MCF_BAUDRATE=19200
442CONFIG_SERIAL_MCF_CONSOLE=y
422# CONFIG_UNIX98_PTYS is not set 443# CONFIG_UNIX98_PTYS is not set
423CONFIG_LEGACY_PTYS=y 444CONFIG_LEGACY_PTYS=y
424CONFIG_LEGACY_PTY_COUNT=256 445CONFIG_LEGACY_PTY_COUNT=256
425# CONFIG_IPMI_HANDLER is not set 446# CONFIG_IPMI_HANDLER is not set
426# CONFIG_WATCHDOG is not set
427# CONFIG_HW_RANDOM is not set 447# CONFIG_HW_RANDOM is not set
428# CONFIG_GEN_RTC is not set 448# CONFIG_GEN_RTC is not set
429# CONFIG_R3964 is not set 449# CONFIG_R3964 is not set
@@ -439,6 +459,14 @@ CONFIG_LEGACY_PTY_COUNT=256
439# CONFIG_W1 is not set 459# CONFIG_W1 is not set
440# CONFIG_POWER_SUPPLY is not set 460# CONFIG_POWER_SUPPLY is not set
441# CONFIG_HWMON is not set 461# CONFIG_HWMON is not set
462# CONFIG_THERMAL is not set
463# CONFIG_WATCHDOG is not set
464
465#
466# Sonics Silicon Backplane
467#
468CONFIG_SSB_POSSIBLE=y
469# CONFIG_SSB is not set
442 470
443# 471#
444# Multifunction device drivers 472# Multifunction device drivers
@@ -450,20 +478,20 @@ CONFIG_LEGACY_PTY_COUNT=256
450# 478#
451# CONFIG_VIDEO_DEV is not set 479# CONFIG_VIDEO_DEV is not set
452# CONFIG_DVB_CORE is not set 480# CONFIG_DVB_CORE is not set
453CONFIG_DAB=y 481# CONFIG_DAB is not set
454 482
455# 483#
456# Graphics support 484# Graphics support
457# 485#
486# CONFIG_VGASTATE is not set
487# CONFIG_VIDEO_OUTPUT_CONTROL is not set
488# CONFIG_FB is not set
458# CONFIG_BACKLIGHT_LCD_SUPPORT is not set 489# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
459 490
460# 491#
461# Display device support 492# Display device support
462# 493#
463# CONFIG_DISPLAY_SUPPORT is not set 494# CONFIG_DISPLAY_SUPPORT is not set
464# CONFIG_VGASTATE is not set
465CONFIG_VIDEO_OUTPUT_CONTROL=y
466# CONFIG_FB is not set
467 495
468# 496#
469# Sound 497# Sound
@@ -471,23 +499,11 @@ CONFIG_VIDEO_OUTPUT_CONTROL=y
471# CONFIG_SOUND is not set 499# CONFIG_SOUND is not set
472# CONFIG_USB_SUPPORT is not set 500# CONFIG_USB_SUPPORT is not set
473# CONFIG_MMC is not set 501# CONFIG_MMC is not set
502# CONFIG_MEMSTICK is not set
474# CONFIG_NEW_LEDS is not set 503# CONFIG_NEW_LEDS is not set
475# CONFIG_RTC_CLASS is not set 504# CONFIG_RTC_CLASS is not set
476 505
477# 506#
478# DMA Engine support
479#
480# CONFIG_DMA_ENGINE is not set
481
482#
483# DMA Clients
484#
485
486#
487# DMA Devices
488#
489
490#
491# Userspace I/O 507# Userspace I/O
492# 508#
493# CONFIG_UIO is not set 509# CONFIG_UIO is not set
@@ -505,11 +521,9 @@ CONFIG_EXT2_FS=y
505# CONFIG_XFS_FS is not set 521# CONFIG_XFS_FS is not set
506# CONFIG_GFS2_FS is not set 522# CONFIG_GFS2_FS is not set
507# CONFIG_OCFS2_FS is not set 523# CONFIG_OCFS2_FS is not set
508# CONFIG_MINIX_FS is not set 524# CONFIG_DNOTIFY is not set
509CONFIG_ROMFS_FS=y
510# CONFIG_INOTIFY is not set 525# CONFIG_INOTIFY is not set
511# CONFIG_QUOTA is not set 526# CONFIG_QUOTA is not set
512# CONFIG_DNOTIFY is not set
513# CONFIG_AUTOFS_FS is not set 527# CONFIG_AUTOFS_FS is not set
514# CONFIG_AUTOFS4_FS is not set 528# CONFIG_AUTOFS4_FS is not set
515# CONFIG_FUSE_FS is not set 529# CONFIG_FUSE_FS is not set
@@ -535,7 +549,6 @@ CONFIG_PROC_SYSCTL=y
535CONFIG_SYSFS=y 549CONFIG_SYSFS=y
536# CONFIG_TMPFS is not set 550# CONFIG_TMPFS is not set
537# CONFIG_HUGETLB_PAGE is not set 551# CONFIG_HUGETLB_PAGE is not set
538CONFIG_RAMFS=y
539# CONFIG_CONFIGFS_FS is not set 552# CONFIG_CONFIGFS_FS is not set
540 553
541# 554#
@@ -551,42 +564,27 @@ CONFIG_RAMFS=y
551# CONFIG_JFFS2_FS is not set 564# CONFIG_JFFS2_FS is not set
552# CONFIG_CRAMFS is not set 565# CONFIG_CRAMFS is not set
553# CONFIG_VXFS_FS is not set 566# CONFIG_VXFS_FS is not set
567# CONFIG_MINIX_FS is not set
554# CONFIG_HPFS_FS is not set 568# CONFIG_HPFS_FS is not set
555# CONFIG_QNX4FS_FS is not set 569# CONFIG_QNX4FS_FS is not set
570CONFIG_ROMFS_FS=y
556# CONFIG_SYSV_FS is not set 571# CONFIG_SYSV_FS is not set
557# CONFIG_UFS_FS is not set 572# CONFIG_UFS_FS is not set
558 573# CONFIG_NETWORK_FILESYSTEMS is not set
559#
560# Network File Systems
561#
562# CONFIG_NFS_FS is not set
563# CONFIG_NFSD is not set
564# CONFIG_SMB_FS is not set
565# CONFIG_CIFS is not set
566# CONFIG_NCP_FS is not set
567# CONFIG_CODA_FS is not set
568# CONFIG_AFS_FS is not set
569 574
570# 575#
571# Partition Types 576# Partition Types
572# 577#
573# CONFIG_PARTITION_ADVANCED is not set 578# CONFIG_PARTITION_ADVANCED is not set
574CONFIG_MSDOS_PARTITION=y 579CONFIG_MSDOS_PARTITION=y
575
576#
577# Native Language Support
578#
579# CONFIG_NLS is not set 580# CONFIG_NLS is not set
580
581#
582# Distributed Lock Manager
583#
584# CONFIG_DLM is not set 581# CONFIG_DLM is not set
585 582
586# 583#
587# Kernel hacking 584# Kernel hacking
588# 585#
589# CONFIG_PRINTK_TIME is not set 586# CONFIG_PRINTK_TIME is not set
587CONFIG_ENABLE_WARN_DEPRECATED=y
590# CONFIG_ENABLE_MUST_CHECK is not set 588# CONFIG_ENABLE_MUST_CHECK is not set
591# CONFIG_MAGIC_SYSRQ is not set 589# CONFIG_MAGIC_SYSRQ is not set
592# CONFIG_UNUSED_SYMBOLS is not set 590# CONFIG_UNUSED_SYMBOLS is not set
@@ -594,6 +592,7 @@ CONFIG_MSDOS_PARTITION=y
594# CONFIG_HEADERS_CHECK is not set 592# CONFIG_HEADERS_CHECK is not set
595# CONFIG_DEBUG_KERNEL is not set 593# CONFIG_DEBUG_KERNEL is not set
596# CONFIG_DEBUG_BUGVERBOSE is not set 594# CONFIG_DEBUG_BUGVERBOSE is not set
595# CONFIG_SAMPLES is not set
597# CONFIG_FULLDEBUG is not set 596# CONFIG_FULLDEBUG is not set
598# CONFIG_HIGHPROFILE is not set 597# CONFIG_HIGHPROFILE is not set
599# CONFIG_BOOTPARAM is not set 598# CONFIG_BOOTPARAM is not set
@@ -605,6 +604,7 @@ CONFIG_MSDOS_PARTITION=y
605# 604#
606# CONFIG_KEYS is not set 605# CONFIG_KEYS is not set
607# CONFIG_SECURITY is not set 606# CONFIG_SECURITY is not set
607# CONFIG_SECURITY_FILE_CAPABILITIES is not set
608# CONFIG_CRYPTO is not set 608# CONFIG_CRYPTO is not set
609 609
610# 610#
diff --git a/arch/m68knommu/kernel/syscalltable.S b/arch/m68knommu/kernel/syscalltable.S
index 1b02b8820068..fca2e49917a3 100644
--- a/arch/m68knommu/kernel/syscalltable.S
+++ b/arch/m68knommu/kernel/syscalltable.S
@@ -336,9 +336,11 @@ ENTRY(sys_call_table)
336 .long sys_epoll_pwait /* 315 */ 336 .long sys_epoll_pwait /* 315 */
337 .long sys_utimensat 337 .long sys_utimensat
338 .long sys_signalfd 338 .long sys_signalfd
339 .long sys_ni_syscall 339 .long sys_timerfd_create
340 .long sys_eventfd 340 .long sys_eventfd
341 .long sys_fallocate /* 320 */ 341 .long sys_fallocate /* 320 */
342 .long sys_timerfd_settime
343 .long sys_timerfd_gettime
342 344
343 .rept NR_syscalls-(.-sys_call_table)/4 345 .rept NR_syscalls-(.-sys_call_table)/4
344 .long sys_ni_syscall 346 .long sys_ni_syscall
diff --git a/arch/m68knommu/platform/68328/timers.c b/arch/m68knommu/platform/68328/timers.c
index 9159fd05c9ac..6bafefa546e5 100644
--- a/arch/m68knommu/platform/68328/timers.c
+++ b/arch/m68knommu/platform/68328/timers.c
@@ -67,16 +67,6 @@ static irqreturn_t hw_tick(int irq, void *dummy)
67 67
68/***************************************************************************/ 68/***************************************************************************/
69 69
70static irqreturn_t hw_tick(int irq, void *dummy)
71{
72 /* Reset Timer1 */
73 TSTAT &= 0;
74
75 return arch_timer_interrupt(irq, dummy);
76}
77
78/***************************************************************************/
79
80static struct irqaction m68328_timer_irq = { 70static struct irqaction m68328_timer_irq = {
81 .name = "timer", 71 .name = "timer",
82 .flags = IRQF_DISABLED | IRQF_TIMER, 72 .flags = IRQF_DISABLED | IRQF_TIMER,
diff --git a/arch/powerpc/boot/cuboot-bamboo.c b/arch/powerpc/boot/cuboot-bamboo.c
index 900c7ff2b7e9..b5c30f766c40 100644
--- a/arch/powerpc/boot/cuboot-bamboo.c
+++ b/arch/powerpc/boot/cuboot-bamboo.c
@@ -17,6 +17,7 @@
17#include "44x.h" 17#include "44x.h"
18#include "cuboot.h" 18#include "cuboot.h"
19 19
20#define TARGET_4xx
20#define TARGET_44x 21#define TARGET_44x
21#include "ppcboot.h" 22#include "ppcboot.h"
22 23
diff --git a/arch/powerpc/boot/cuboot-ebony.c b/arch/powerpc/boot/cuboot-ebony.c
index c5f37ce172ea..56564ba37f62 100644
--- a/arch/powerpc/boot/cuboot-ebony.c
+++ b/arch/powerpc/boot/cuboot-ebony.c
@@ -17,6 +17,7 @@
17#include "44x.h" 17#include "44x.h"
18#include "cuboot.h" 18#include "cuboot.h"
19 19
20#define TARGET_4xx
20#define TARGET_44x 21#define TARGET_44x
21#include "ppcboot.h" 22#include "ppcboot.h"
22 23
diff --git a/arch/powerpc/boot/cuboot-katmai.c b/arch/powerpc/boot/cuboot-katmai.c
index c021167f9381..5434d70b5660 100644
--- a/arch/powerpc/boot/cuboot-katmai.c
+++ b/arch/powerpc/boot/cuboot-katmai.c
@@ -22,6 +22,7 @@
22#include "44x.h" 22#include "44x.h"
23#include "cuboot.h" 23#include "cuboot.h"
24 24
25#define TARGET_4xx
25#define TARGET_44x 26#define TARGET_44x
26#include "ppcboot.h" 27#include "ppcboot.h"
27 28
diff --git a/arch/powerpc/boot/cuboot-taishan.c b/arch/powerpc/boot/cuboot-taishan.c
index f66455a45ab1..b55b80467eed 100644
--- a/arch/powerpc/boot/cuboot-taishan.c
+++ b/arch/powerpc/boot/cuboot-taishan.c
@@ -21,7 +21,9 @@
21#include "dcr.h" 21#include "dcr.h"
22#include "4xx.h" 22#include "4xx.h"
23 23
24#define TARGET_4xx
24#define TARGET_44x 25#define TARGET_44x
26#define TARGET_440GX
25#include "ppcboot.h" 27#include "ppcboot.h"
26 28
27static bd_t bd; 29static bd_t bd;
diff --git a/arch/powerpc/boot/cuboot-warp.c b/arch/powerpc/boot/cuboot-warp.c
index bdedebe1bc14..3db93e85e9ea 100644
--- a/arch/powerpc/boot/cuboot-warp.c
+++ b/arch/powerpc/boot/cuboot-warp.c
@@ -11,6 +11,7 @@
11#include "4xx.h" 11#include "4xx.h"
12#include "cuboot.h" 12#include "cuboot.h"
13 13
14#define TARGET_4xx
14#define TARGET_44x 15#define TARGET_44x
15#include "ppcboot.h" 16#include "ppcboot.h"
16 17
diff --git a/arch/powerpc/boot/dts/haleakala.dts b/arch/powerpc/boot/dts/haleakala.dts
index 5dd3d15f0feb..ae68fefc01b6 100644
--- a/arch/powerpc/boot/dts/haleakala.dts
+++ b/arch/powerpc/boot/dts/haleakala.dts
@@ -235,7 +235,7 @@
235 #interrupt-cells = <1>; 235 #interrupt-cells = <1>;
236 #size-cells = <2>; 236 #size-cells = <2>;
237 #address-cells = <3>; 237 #address-cells = <3>;
238 compatible = "ibm,plb-pciex-405exr", "ibm,plb-pciex"; 238 compatible = "ibm,plb-pciex-405ex", "ibm,plb-pciex";
239 primary; 239 primary;
240 port = <0>; /* port number */ 240 port = <0>; /* port number */
241 reg = <a0000000 20000000 /* Config space access */ 241 reg = <a0000000 20000000 /* Config space access */
diff --git a/arch/powerpc/boot/dts/katmai.dts b/arch/powerpc/boot/dts/katmai.dts
index bc32ac7250ec..fc86e5a3afc4 100644
--- a/arch/powerpc/boot/dts/katmai.dts
+++ b/arch/powerpc/boot/dts/katmai.dts
@@ -38,8 +38,8 @@
38 timebase-frequency = <0>; /* Filled in by zImage */ 38 timebase-frequency = <0>; /* Filled in by zImage */
39 i-cache-line-size = <20>; 39 i-cache-line-size = <20>;
40 d-cache-line-size = <20>; 40 d-cache-line-size = <20>;
41 i-cache-size = <20000>; 41 i-cache-size = <8000>;
42 d-cache-size = <20000>; 42 d-cache-size = <8000>;
43 dcr-controller; 43 dcr-controller;
44 dcr-access-method = "native"; 44 dcr-access-method = "native";
45 }; 45 };
@@ -136,11 +136,11 @@
136 }; 136 };
137 137
138 POB0: opb { 138 POB0: opb {
139 compatible = "ibm,opb-440spe", "ibm,opb-440gp", "ibm,opb"; 139 compatible = "ibm,opb-440spe", "ibm,opb-440gp", "ibm,opb";
140 #address-cells = <1>; 140 #address-cells = <1>;
141 #size-cells = <1>; 141 #size-cells = <1>;
142 ranges = <00000000 4 e0000000 20000000>; 142 ranges = <00000000 4 e0000000 20000000>;
143 clock-frequency = <0>; /* Filled in by zImage */ 143 clock-frequency = <0>; /* Filled in by zImage */
144 144
145 EBC0: ebc { 145 EBC0: ebc {
146 compatible = "ibm,ebc-440spe", "ibm,ebc-440gp", "ibm,ebc"; 146 compatible = "ibm,ebc-440spe", "ibm,ebc-440gp", "ibm,ebc";
@@ -153,38 +153,38 @@
153 }; 153 };
154 154
155 UART0: serial@10000200 { 155 UART0: serial@10000200 {
156 device_type = "serial"; 156 device_type = "serial";
157 compatible = "ns16550"; 157 compatible = "ns16550";
158 reg = <10000200 8>; 158 reg = <10000200 8>;
159 virtual-reg = <a0000200>; 159 virtual-reg = <a0000200>;
160 clock-frequency = <0>; /* Filled in by zImage */ 160 clock-frequency = <0>; /* Filled in by zImage */
161 current-speed = <1c200>; 161 current-speed = <1c200>;
162 interrupt-parent = <&UIC0>; 162 interrupt-parent = <&UIC0>;
163 interrupts = <0 4>; 163 interrupts = <0 4>;
164 }; 164 };
165 165
166 UART1: serial@10000300 { 166 UART1: serial@10000300 {
167 device_type = "serial"; 167 device_type = "serial";
168 compatible = "ns16550"; 168 compatible = "ns16550";
169 reg = <10000300 8>; 169 reg = <10000300 8>;
170 virtual-reg = <a0000300>; 170 virtual-reg = <a0000300>;
171 clock-frequency = <0>; 171 clock-frequency = <0>;
172 current-speed = <0>; 172 current-speed = <0>;
173 interrupt-parent = <&UIC0>; 173 interrupt-parent = <&UIC0>;
174 interrupts = <1 4>; 174 interrupts = <1 4>;
175 }; 175 };
176 176
177 177
178 UART2: serial@10000600 { 178 UART2: serial@10000600 {
179 device_type = "serial"; 179 device_type = "serial";
180 compatible = "ns16550"; 180 compatible = "ns16550";
181 reg = <10000600 8>; 181 reg = <10000600 8>;
182 virtual-reg = <a0000600>; 182 virtual-reg = <a0000600>;
183 clock-frequency = <0>; 183 clock-frequency = <0>;
184 current-speed = <0>; 184 current-speed = <0>;
185 interrupt-parent = <&UIC1>; 185 interrupt-parent = <&UIC1>;
186 interrupts = <5 4>; 186 interrupts = <5 4>;
187 }; 187 };
188 188
189 IIC0: i2c@10000400 { 189 IIC0: i2c@10000400 {
190 compatible = "ibm,iic-440spe", "ibm,iic-440gp", "ibm,iic"; 190 compatible = "ibm,iic-440spe", "ibm,iic-440gp", "ibm,iic";
diff --git a/arch/powerpc/oprofile/op_model_cell.c b/arch/powerpc/oprofile/op_model_cell.c
index 13929771bee7..9eed1f68fcab 100644
--- a/arch/powerpc/oprofile/op_model_cell.c
+++ b/arch/powerpc/oprofile/op_model_cell.c
@@ -1151,7 +1151,7 @@ static void cell_handle_interrupt(struct pt_regs *regs,
1151 for (i = 0; i < num_counters; ++i) { 1151 for (i = 0; i < num_counters; ++i) {
1152 if ((interrupt_mask & CBE_PM_CTR_OVERFLOW_INTR(i)) 1152 if ((interrupt_mask & CBE_PM_CTR_OVERFLOW_INTR(i))
1153 && ctr[i].enabled) { 1153 && ctr[i].enabled) {
1154 oprofile_add_pc(pc, is_kernel, i); 1154 oprofile_add_ext_sample(pc, regs, i, is_kernel);
1155 cbe_write_ctr(cpu, i, reset_value[i]); 1155 cbe_write_ctr(cpu, i, reset_value[i]);
1156 } 1156 }
1157 } 1157 }
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_common.c b/arch/powerpc/platforms/52xx/mpc52xx_common.c
index 9aa4425d80b2..4d5fd1dbd400 100644
--- a/arch/powerpc/platforms/52xx/mpc52xx_common.c
+++ b/arch/powerpc/platforms/52xx/mpc52xx_common.c
@@ -199,6 +199,7 @@ int mpc52xx_set_psc_clkdiv(int psc_id, int clkdiv)
199 199
200 return 0; 200 return 0;
201} 201}
202EXPORT_SYMBOL(mpc52xx_set_psc_clkdiv);
202 203
203/** 204/**
204 * mpc52xx_restart: ppc_md->restart hook for mpc5200 using the watchdog timer 205 * mpc52xx_restart: ppc_md->restart hook for mpc5200 using the watchdog timer
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index edab631a8dcb..20ea0e118f24 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -113,7 +113,7 @@
113 113
114/* IOMMU sizing */ 114/* IOMMU sizing */
115#define IO_SEGMENT_SHIFT 28 115#define IO_SEGMENT_SHIFT 28
116#define IO_PAGENO_BITS (IO_SEGMENT_SHIFT - IOMMU_PAGE_SHIFT) 116#define IO_PAGENO_BITS(shift) (IO_SEGMENT_SHIFT - (shift))
117 117
118/* The high bit needs to be set on every DMA address */ 118/* The high bit needs to be set on every DMA address */
119#define SPIDER_DMA_OFFSET 0x80000000ul 119#define SPIDER_DMA_OFFSET 0x80000000ul
@@ -123,7 +123,6 @@ struct iommu_window {
123 struct cbe_iommu *iommu; 123 struct cbe_iommu *iommu;
124 unsigned long offset; 124 unsigned long offset;
125 unsigned long size; 125 unsigned long size;
126 unsigned long pte_offset;
127 unsigned int ioid; 126 unsigned int ioid;
128 struct iommu_table table; 127 struct iommu_table table;
129}; 128};
@@ -200,7 +199,7 @@ static void tce_build_cell(struct iommu_table *tbl, long index, long npages,
200 (window->ioid & IOPTE_IOID_Mask); 199 (window->ioid & IOPTE_IOID_Mask);
201#endif 200#endif
202 201
203 io_pte = (unsigned long *)tbl->it_base + (index - window->pte_offset); 202 io_pte = (unsigned long *)tbl->it_base + (index - tbl->it_offset);
204 203
205 for (i = 0; i < npages; i++, uaddr += IOMMU_PAGE_SIZE) 204 for (i = 0; i < npages; i++, uaddr += IOMMU_PAGE_SIZE)
206 io_pte[i] = base_pte | (__pa(uaddr) & IOPTE_RPN_Mask); 205 io_pte[i] = base_pte | (__pa(uaddr) & IOPTE_RPN_Mask);
@@ -232,7 +231,7 @@ static void tce_free_cell(struct iommu_table *tbl, long index, long npages)
232 | (window->ioid & IOPTE_IOID_Mask); 231 | (window->ioid & IOPTE_IOID_Mask);
233#endif 232#endif
234 233
235 io_pte = (unsigned long *)tbl->it_base + (index - window->pte_offset); 234 io_pte = (unsigned long *)tbl->it_base + (index - tbl->it_offset);
236 235
237 for (i = 0; i < npages; i++) 236 for (i = 0; i < npages; i++)
238 io_pte[i] = pte; 237 io_pte[i] = pte;
@@ -307,76 +306,84 @@ static int cell_iommu_find_ioc(int nid, unsigned long *base)
307 return -ENODEV; 306 return -ENODEV;
308} 307}
309 308
310static void cell_iommu_setup_page_tables(struct cbe_iommu *iommu, 309static void cell_iommu_setup_stab(struct cbe_iommu *iommu,
311 unsigned long dbase, unsigned long dsize, 310 unsigned long dbase, unsigned long dsize,
312 unsigned long fbase, unsigned long fsize) 311 unsigned long fbase, unsigned long fsize)
313{ 312{
314 struct page *page; 313 struct page *page;
315 int i; 314 unsigned long segments, stab_size;
316 unsigned long reg, segments, pages_per_segment, ptab_size, stab_size,
317 n_pte_pages, base;
318
319 base = dbase;
320 if (fsize != 0)
321 base = min(fbase, dbase);
322 315
323 segments = max(dbase + dsize, fbase + fsize) >> IO_SEGMENT_SHIFT; 316 segments = max(dbase + dsize, fbase + fsize) >> IO_SEGMENT_SHIFT;
324 pages_per_segment = 1ull << IO_PAGENO_BITS;
325 317
326 pr_debug("%s: iommu[%d]: segments: %lu, pages per segment: %lu\n", 318 pr_debug("%s: iommu[%d]: segments: %lu\n",
327 __FUNCTION__, iommu->nid, segments, pages_per_segment); 319 __FUNCTION__, iommu->nid, segments);
328 320
329 /* set up the segment table */ 321 /* set up the segment table */
330 stab_size = segments * sizeof(unsigned long); 322 stab_size = segments * sizeof(unsigned long);
331 page = alloc_pages_node(iommu->nid, GFP_KERNEL, get_order(stab_size)); 323 page = alloc_pages_node(iommu->nid, GFP_KERNEL, get_order(stab_size));
332 BUG_ON(!page); 324 BUG_ON(!page);
333 iommu->stab = page_address(page); 325 iommu->stab = page_address(page);
334 clear_page(iommu->stab); 326 memset(iommu->stab, 0, stab_size);
327}
328
329static unsigned long *cell_iommu_alloc_ptab(struct cbe_iommu *iommu,
330 unsigned long base, unsigned long size, unsigned long gap_base,
331 unsigned long gap_size, unsigned long page_shift)
332{
333 struct page *page;
334 int i;
335 unsigned long reg, segments, pages_per_segment, ptab_size,
336 n_pte_pages, start_seg, *ptab;
337
338 start_seg = base >> IO_SEGMENT_SHIFT;
339 segments = size >> IO_SEGMENT_SHIFT;
340 pages_per_segment = 1ull << IO_PAGENO_BITS(page_shift);
341 /* PTEs for each segment must start on a 4K bounday */
342 pages_per_segment = max(pages_per_segment,
343 (1 << 12) / sizeof(unsigned long));
335 344
336 /* ... and the page tables. Since these are contiguous, we can treat
337 * the page tables as one array of ptes, like pSeries does.
338 */
339 ptab_size = segments * pages_per_segment * sizeof(unsigned long); 345 ptab_size = segments * pages_per_segment * sizeof(unsigned long);
340 pr_debug("%s: iommu[%d]: ptab_size: %lu, order: %d\n", __FUNCTION__, 346 pr_debug("%s: iommu[%d]: ptab_size: %lu, order: %d\n", __FUNCTION__,
341 iommu->nid, ptab_size, get_order(ptab_size)); 347 iommu->nid, ptab_size, get_order(ptab_size));
342 page = alloc_pages_node(iommu->nid, GFP_KERNEL, get_order(ptab_size)); 348 page = alloc_pages_node(iommu->nid, GFP_KERNEL, get_order(ptab_size));
343 BUG_ON(!page); 349 BUG_ON(!page);
344 350
345 iommu->ptab = page_address(page); 351 ptab = page_address(page);
346 memset(iommu->ptab, 0, ptab_size); 352 memset(ptab, 0, ptab_size);
347 353
348 /* allocate a bogus page for the end of each mapping */ 354 /* number of 4K pages needed for a page table */
349 page = alloc_pages_node(iommu->nid, GFP_KERNEL, 0); 355 n_pte_pages = (pages_per_segment * sizeof(unsigned long)) >> 12;
350 BUG_ON(!page);
351 iommu->pad_page = page_address(page);
352 clear_page(iommu->pad_page);
353
354 /* number of pages needed for a page table */
355 n_pte_pages = (pages_per_segment *
356 sizeof(unsigned long)) >> IOMMU_PAGE_SHIFT;
357 356
358 pr_debug("%s: iommu[%d]: stab at %p, ptab at %p, n_pte_pages: %lu\n", 357 pr_debug("%s: iommu[%d]: stab at %p, ptab at %p, n_pte_pages: %lu\n",
359 __FUNCTION__, iommu->nid, iommu->stab, iommu->ptab, 358 __FUNCTION__, iommu->nid, iommu->stab, ptab,
360 n_pte_pages); 359 n_pte_pages);
361 360
362 /* initialise the STEs */ 361 /* initialise the STEs */
363 reg = IOSTE_V | ((n_pte_pages - 1) << 5); 362 reg = IOSTE_V | ((n_pte_pages - 1) << 5);
364 363
365 if (IOMMU_PAGE_SIZE == 0x1000) 364 switch (page_shift) {
366 reg |= IOSTE_PS_4K; 365 case 12: reg |= IOSTE_PS_4K; break;
367 else if (IOMMU_PAGE_SIZE == 0x10000) 366 case 16: reg |= IOSTE_PS_64K; break;
368 reg |= IOSTE_PS_64K; 367 case 20: reg |= IOSTE_PS_1M; break;
369 else { 368 case 24: reg |= IOSTE_PS_16M; break;
370 extern void __unknown_page_size_error(void); 369 default: BUG();
371 __unknown_page_size_error();
372 } 370 }
373 371
372 gap_base = gap_base >> IO_SEGMENT_SHIFT;
373 gap_size = gap_size >> IO_SEGMENT_SHIFT;
374
374 pr_debug("Setting up IOMMU stab:\n"); 375 pr_debug("Setting up IOMMU stab:\n");
375 for (i = base >> IO_SEGMENT_SHIFT; i < segments; i++) { 376 for (i = start_seg; i < (start_seg + segments); i++) {
376 iommu->stab[i] = reg | 377 if (i >= gap_base && i < (gap_base + gap_size)) {
377 (__pa(iommu->ptab) + n_pte_pages * IOMMU_PAGE_SIZE * i); 378 pr_debug("\toverlap at %d, skipping\n", i);
379 continue;
380 }
381 iommu->stab[i] = reg | (__pa(ptab) + (n_pte_pages << 12) *
382 (i - start_seg));
378 pr_debug("\t[%d] 0x%016lx\n", i, iommu->stab[i]); 383 pr_debug("\t[%d] 0x%016lx\n", i, iommu->stab[i]);
379 } 384 }
385
386 return ptab;
380} 387}
381 388
382static void cell_iommu_enable_hardware(struct cbe_iommu *iommu) 389static void cell_iommu_enable_hardware(struct cbe_iommu *iommu)
@@ -423,7 +430,9 @@ static void cell_iommu_enable_hardware(struct cbe_iommu *iommu)
423static void cell_iommu_setup_hardware(struct cbe_iommu *iommu, 430static void cell_iommu_setup_hardware(struct cbe_iommu *iommu,
424 unsigned long base, unsigned long size) 431 unsigned long base, unsigned long size)
425{ 432{
426 cell_iommu_setup_page_tables(iommu, base, size, 0, 0); 433 cell_iommu_setup_stab(iommu, base, size, 0, 0);
434 iommu->ptab = cell_iommu_alloc_ptab(iommu, base, size, 0, 0,
435 IOMMU_PAGE_SHIFT);
427 cell_iommu_enable_hardware(iommu); 436 cell_iommu_enable_hardware(iommu);
428} 437}
429 438
@@ -464,6 +473,7 @@ cell_iommu_setup_window(struct cbe_iommu *iommu, struct device_node *np,
464 unsigned long pte_offset) 473 unsigned long pte_offset)
465{ 474{
466 struct iommu_window *window; 475 struct iommu_window *window;
476 struct page *page;
467 u32 ioid; 477 u32 ioid;
468 478
469 ioid = cell_iommu_get_ioid(np); 479 ioid = cell_iommu_get_ioid(np);
@@ -475,13 +485,11 @@ cell_iommu_setup_window(struct cbe_iommu *iommu, struct device_node *np,
475 window->size = size; 485 window->size = size;
476 window->ioid = ioid; 486 window->ioid = ioid;
477 window->iommu = iommu; 487 window->iommu = iommu;
478 window->pte_offset = pte_offset;
479 488
480 window->table.it_blocksize = 16; 489 window->table.it_blocksize = 16;
481 window->table.it_base = (unsigned long)iommu->ptab; 490 window->table.it_base = (unsigned long)iommu->ptab;
482 window->table.it_index = iommu->nid; 491 window->table.it_index = iommu->nid;
483 window->table.it_offset = (offset >> IOMMU_PAGE_SHIFT) + 492 window->table.it_offset = (offset >> IOMMU_PAGE_SHIFT) + pte_offset;
484 window->pte_offset;
485 window->table.it_size = size >> IOMMU_PAGE_SHIFT; 493 window->table.it_size = size >> IOMMU_PAGE_SHIFT;
486 494
487 iommu_init_table(&window->table, iommu->nid); 495 iommu_init_table(&window->table, iommu->nid);
@@ -504,6 +512,11 @@ cell_iommu_setup_window(struct cbe_iommu *iommu, struct device_node *np,
504 * This code also assumes that we have a window that starts at 0, 512 * This code also assumes that we have a window that starts at 0,
505 * which is the case on all spider based blades. 513 * which is the case on all spider based blades.
506 */ 514 */
515 page = alloc_pages_node(iommu->nid, GFP_KERNEL, 0);
516 BUG_ON(!page);
517 iommu->pad_page = page_address(page);
518 clear_page(iommu->pad_page);
519
507 __set_bit(0, window->table.it_map); 520 __set_bit(0, window->table.it_map);
508 tce_build_cell(&window->table, window->table.it_offset, 1, 521 tce_build_cell(&window->table, window->table.it_offset, 1,
509 (unsigned long)iommu->pad_page, DMA_TO_DEVICE); 522 (unsigned long)iommu->pad_page, DMA_TO_DEVICE);
@@ -549,7 +562,7 @@ static void cell_dma_dev_setup_iommu(struct device *dev)
549 archdata->dma_data = &window->table; 562 archdata->dma_data = &window->table;
550} 563}
551 564
552static void cell_dma_dev_setup_static(struct device *dev); 565static void cell_dma_dev_setup_fixed(struct device *dev);
553 566
554static void cell_dma_dev_setup(struct device *dev) 567static void cell_dma_dev_setup(struct device *dev)
555{ 568{
@@ -557,7 +570,7 @@ static void cell_dma_dev_setup(struct device *dev)
557 570
558 /* Order is important here, these are not mutually exclusive */ 571 /* Order is important here, these are not mutually exclusive */
559 if (get_dma_ops(dev) == &dma_iommu_fixed_ops) 572 if (get_dma_ops(dev) == &dma_iommu_fixed_ops)
560 cell_dma_dev_setup_static(dev); 573 cell_dma_dev_setup_fixed(dev);
561 else if (get_pci_dma_ops() == &dma_iommu_ops) 574 else if (get_pci_dma_ops() == &dma_iommu_ops)
562 cell_dma_dev_setup_iommu(dev); 575 cell_dma_dev_setup_iommu(dev);
563 else if (get_pci_dma_ops() == &dma_direct_ops) 576 else if (get_pci_dma_ops() == &dma_direct_ops)
@@ -858,7 +871,7 @@ static int dma_set_mask_and_switch(struct device *dev, u64 dma_mask)
858 return 0; 871 return 0;
859} 872}
860 873
861static void cell_dma_dev_setup_static(struct device *dev) 874static void cell_dma_dev_setup_fixed(struct device *dev)
862{ 875{
863 struct dev_archdata *archdata = &dev->archdata; 876 struct dev_archdata *archdata = &dev->archdata;
864 u64 addr; 877 u64 addr;
@@ -869,35 +882,45 @@ static void cell_dma_dev_setup_static(struct device *dev)
869 dev_dbg(dev, "iommu: fixed addr = %lx\n", addr); 882 dev_dbg(dev, "iommu: fixed addr = %lx\n", addr);
870} 883}
871 884
885static void insert_16M_pte(unsigned long addr, unsigned long *ptab,
886 unsigned long base_pte)
887{
888 unsigned long segment, offset;
889
890 segment = addr >> IO_SEGMENT_SHIFT;
891 offset = (addr >> 24) - (segment << IO_PAGENO_BITS(24));
892 ptab = ptab + (segment * (1 << 12) / sizeof(unsigned long));
893
894 pr_debug("iommu: addr %lx ptab %p segment %lx offset %lx\n",
895 addr, ptab, segment, offset);
896
897 ptab[offset] = base_pte | (__pa(addr) & IOPTE_RPN_Mask);
898}
899
872static void cell_iommu_setup_fixed_ptab(struct cbe_iommu *iommu, 900static void cell_iommu_setup_fixed_ptab(struct cbe_iommu *iommu,
873 struct device_node *np, unsigned long dbase, unsigned long dsize, 901 struct device_node *np, unsigned long dbase, unsigned long dsize,
874 unsigned long fbase, unsigned long fsize) 902 unsigned long fbase, unsigned long fsize)
875{ 903{
876 unsigned long base_pte, uaddr, *io_pte; 904 unsigned long base_pte, uaddr, ioaddr, *ptab;
877 int i;
878 905
879 dma_iommu_fixed_base = fbase; 906 ptab = cell_iommu_alloc_ptab(iommu, fbase, fsize, dbase, dsize, 24);
880 907
881 /* convert from bytes into page table indices */ 908 dma_iommu_fixed_base = fbase;
882 dbase = dbase >> IOMMU_PAGE_SHIFT;
883 dsize = dsize >> IOMMU_PAGE_SHIFT;
884 fbase = fbase >> IOMMU_PAGE_SHIFT;
885 fsize = fsize >> IOMMU_PAGE_SHIFT;
886 909
887 pr_debug("iommu: mapping 0x%lx pages from 0x%lx\n", fsize, fbase); 910 pr_debug("iommu: mapping 0x%lx pages from 0x%lx\n", fsize, fbase);
888 911
889 io_pte = iommu->ptab;
890 base_pte = IOPTE_PP_W | IOPTE_PP_R | IOPTE_M | IOPTE_SO_RW 912 base_pte = IOPTE_PP_W | IOPTE_PP_R | IOPTE_M | IOPTE_SO_RW
891 | (cell_iommu_get_ioid(np) & IOPTE_IOID_Mask); 913 | (cell_iommu_get_ioid(np) & IOPTE_IOID_Mask);
892 914
893 uaddr = 0; 915 for (uaddr = 0; uaddr < fsize; uaddr += (1 << 24)) {
894 for (i = fbase; i < fbase + fsize; i++, uaddr += IOMMU_PAGE_SIZE) {
895 /* Don't touch the dynamic region */ 916 /* Don't touch the dynamic region */
896 if (i >= dbase && i < (dbase + dsize)) { 917 ioaddr = uaddr + fbase;
897 pr_debug("iommu: static/dynamic overlap, skipping\n"); 918 if (ioaddr >= dbase && ioaddr < (dbase + dsize)) {
919 pr_debug("iommu: fixed/dynamic overlap, skipping\n");
898 continue; 920 continue;
899 } 921 }
900 io_pte[i] = base_pte | (__pa(uaddr) & IOPTE_RPN_Mask); 922
923 insert_16M_pte(uaddr, ptab, base_pte);
901 } 924 }
902 925
903 mb(); 926 mb();
@@ -995,7 +1018,9 @@ static int __init cell_iommu_fixed_mapping_init(void)
995 "fixed window 0x%lx-0x%lx\n", iommu->nid, dbase, 1018 "fixed window 0x%lx-0x%lx\n", iommu->nid, dbase,
996 dbase + dsize, fbase, fbase + fsize); 1019 dbase + dsize, fbase, fbase + fsize);
997 1020
998 cell_iommu_setup_page_tables(iommu, dbase, dsize, fbase, fsize); 1021 cell_iommu_setup_stab(iommu, dbase, dsize, fbase, fsize);
1022 iommu->ptab = cell_iommu_alloc_ptab(iommu, dbase, dsize, 0, 0,
1023 IOMMU_PAGE_SHIFT);
999 cell_iommu_setup_fixed_ptab(iommu, np, dbase, dsize, 1024 cell_iommu_setup_fixed_ptab(iommu, np, dbase, dsize,
1000 fbase, fsize); 1025 fbase, fsize);
1001 cell_iommu_enable_hardware(iommu); 1026 cell_iommu_enable_hardware(iommu);
diff --git a/arch/powerpc/platforms/cell/setup.c b/arch/powerpc/platforms/cell/setup.c
index a7f609b3b876..dda34650cb07 100644
--- a/arch/powerpc/platforms/cell/setup.c
+++ b/arch/powerpc/platforms/cell/setup.c
@@ -149,6 +149,11 @@ static void __init cell_init_irq(void)
149 mpic_init_IRQ(); 149 mpic_init_IRQ();
150} 150}
151 151
152static void __init cell_set_dabrx(void)
153{
154 mtspr(SPRN_DABRX, DABRX_KERNEL | DABRX_USER);
155}
156
152static void __init cell_setup_arch(void) 157static void __init cell_setup_arch(void)
153{ 158{
154#ifdef CONFIG_SPU_BASE 159#ifdef CONFIG_SPU_BASE
@@ -158,6 +163,8 @@ static void __init cell_setup_arch(void)
158 163
159 cbe_regs_init(); 164 cbe_regs_init();
160 165
166 cell_set_dabrx();
167
161#ifdef CONFIG_CBE_RAS 168#ifdef CONFIG_CBE_RAS
162 cbe_ras_init(); 169 cbe_ras_init();
163#endif 170#endif
diff --git a/arch/powerpc/platforms/cell/spu_base.c b/arch/powerpc/platforms/cell/spu_base.c
index 87eb07f94c5f..712001f6b7da 100644
--- a/arch/powerpc/platforms/cell/spu_base.c
+++ b/arch/powerpc/platforms/cell/spu_base.c
@@ -81,9 +81,12 @@ struct spu_slb {
81void spu_invalidate_slbs(struct spu *spu) 81void spu_invalidate_slbs(struct spu *spu)
82{ 82{
83 struct spu_priv2 __iomem *priv2 = spu->priv2; 83 struct spu_priv2 __iomem *priv2 = spu->priv2;
84 unsigned long flags;
84 85
86 spin_lock_irqsave(&spu->register_lock, flags);
85 if (spu_mfc_sr1_get(spu) & MFC_STATE1_RELOCATE_MASK) 87 if (spu_mfc_sr1_get(spu) & MFC_STATE1_RELOCATE_MASK)
86 out_be64(&priv2->slb_invalidate_all_W, 0UL); 88 out_be64(&priv2->slb_invalidate_all_W, 0UL);
89 spin_unlock_irqrestore(&spu->register_lock, flags);
87} 90}
88EXPORT_SYMBOL_GPL(spu_invalidate_slbs); 91EXPORT_SYMBOL_GPL(spu_invalidate_slbs);
89 92
@@ -148,7 +151,11 @@ static inline void spu_load_slb(struct spu *spu, int slbe, struct spu_slb *slb)
148 __func__, slbe, slb->vsid, slb->esid); 151 __func__, slbe, slb->vsid, slb->esid);
149 152
150 out_be64(&priv2->slb_index_W, slbe); 153 out_be64(&priv2->slb_index_W, slbe);
154 /* set invalid before writing vsid */
155 out_be64(&priv2->slb_esid_RW, 0);
156 /* now it's safe to write the vsid */
151 out_be64(&priv2->slb_vsid_RW, slb->vsid); 157 out_be64(&priv2->slb_vsid_RW, slb->vsid);
158 /* setting the new esid makes the entry valid again */
152 out_be64(&priv2->slb_esid_RW, slb->esid); 159 out_be64(&priv2->slb_esid_RW, slb->esid);
153} 160}
154 161
@@ -290,9 +297,11 @@ void spu_setup_kernel_slbs(struct spu *spu, struct spu_lscsa *lscsa,
290 nr_slbs++; 297 nr_slbs++;
291 } 298 }
292 299
300 spin_lock_irq(&spu->register_lock);
293 /* Add the set of SLBs */ 301 /* Add the set of SLBs */
294 for (i = 0; i < nr_slbs; i++) 302 for (i = 0; i < nr_slbs; i++)
295 spu_load_slb(spu, i, &slbs[i]); 303 spu_load_slb(spu, i, &slbs[i]);
304 spin_unlock_irq(&spu->register_lock);
296} 305}
297EXPORT_SYMBOL_GPL(spu_setup_kernel_slbs); 306EXPORT_SYMBOL_GPL(spu_setup_kernel_slbs);
298 307
@@ -337,13 +346,14 @@ spu_irq_class_1(int irq, void *data)
337 if (stat & CLASS1_STORAGE_FAULT_INTR) 346 if (stat & CLASS1_STORAGE_FAULT_INTR)
338 spu_mfc_dsisr_set(spu, 0ul); 347 spu_mfc_dsisr_set(spu, 0ul);
339 spu_int_stat_clear(spu, 1, stat); 348 spu_int_stat_clear(spu, 1, stat);
340 spin_unlock(&spu->register_lock);
341 pr_debug("%s: %lx %lx %lx %lx\n", __FUNCTION__, mask, stat,
342 dar, dsisr);
343 349
344 if (stat & CLASS1_SEGMENT_FAULT_INTR) 350 if (stat & CLASS1_SEGMENT_FAULT_INTR)
345 __spu_trap_data_seg(spu, dar); 351 __spu_trap_data_seg(spu, dar);
346 352
353 spin_unlock(&spu->register_lock);
354 pr_debug("%s: %lx %lx %lx %lx\n", __FUNCTION__, mask, stat,
355 dar, dsisr);
356
347 if (stat & CLASS1_STORAGE_FAULT_INTR) 357 if (stat & CLASS1_STORAGE_FAULT_INTR)
348 __spu_trap_data_map(spu, dar, dsisr); 358 __spu_trap_data_map(spu, dar, dsisr);
349 359
diff --git a/arch/powerpc/platforms/cell/spufs/context.c b/arch/powerpc/platforms/cell/spufs/context.c
index 133995ed5cc7..cf6c2c89211d 100644
--- a/arch/powerpc/platforms/cell/spufs/context.c
+++ b/arch/powerpc/platforms/cell/spufs/context.c
@@ -109,13 +109,12 @@ void spu_forget(struct spu_context *ctx)
109 109
110 /* 110 /*
111 * This is basically an open-coded spu_acquire_saved, except that 111 * This is basically an open-coded spu_acquire_saved, except that
112 * we don't acquire the state mutex interruptible. 112 * we don't acquire the state mutex interruptible, and we don't
113 * want this context to be rescheduled on release.
113 */ 114 */
114 mutex_lock(&ctx->state_mutex); 115 mutex_lock(&ctx->state_mutex);
115 if (ctx->state != SPU_STATE_SAVED) { 116 if (ctx->state != SPU_STATE_SAVED)
116 set_bit(SPU_SCHED_WAS_ACTIVE, &ctx->sched_flags);
117 spu_deactivate(ctx); 117 spu_deactivate(ctx);
118 }
119 118
120 mm = ctx->owner; 119 mm = ctx->owner;
121 ctx->owner = NULL; 120 ctx->owner = NULL;
diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index c66c3756970d..f7a7e8635fb6 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -367,6 +367,13 @@ static unsigned long spufs_ps_nopfn(struct vm_area_struct *vma,
367 return NOPFN_SIGBUS; 367 return NOPFN_SIGBUS;
368 368
369 /* 369 /*
370 * Because we release the mmap_sem, the context may be destroyed while
371 * we're in spu_wait. Grab an extra reference so it isn't destroyed
372 * in the meantime.
373 */
374 get_spu_context(ctx);
375
376 /*
370 * We have to wait for context to be loaded before we have 377 * We have to wait for context to be loaded before we have
371 * pages to hand out to the user, but we don't want to wait 378 * pages to hand out to the user, but we don't want to wait
372 * with the mmap_sem held. 379 * with the mmap_sem held.
@@ -375,7 +382,7 @@ static unsigned long spufs_ps_nopfn(struct vm_area_struct *vma,
375 * hanged. 382 * hanged.
376 */ 383 */
377 if (spu_acquire(ctx)) 384 if (spu_acquire(ctx))
378 return NOPFN_REFAULT; 385 goto refault;
379 386
380 if (ctx->state == SPU_STATE_SAVED) { 387 if (ctx->state == SPU_STATE_SAVED) {
381 up_read(&current->mm->mmap_sem); 388 up_read(&current->mm->mmap_sem);
@@ -391,6 +398,9 @@ static unsigned long spufs_ps_nopfn(struct vm_area_struct *vma,
391 398
392 if (!ret) 399 if (!ret)
393 spu_release(ctx); 400 spu_release(ctx);
401
402refault:
403 put_spu_context(ctx);
394 return NOPFN_REFAULT; 404 return NOPFN_REFAULT;
395} 405}
396 406
diff --git a/arch/powerpc/platforms/cell/spufs/sched.c b/arch/powerpc/platforms/cell/spufs/sched.c
index 3a5972117de7..5d5f680cd0b8 100644
--- a/arch/powerpc/platforms/cell/spufs/sched.c
+++ b/arch/powerpc/platforms/cell/spufs/sched.c
@@ -246,7 +246,7 @@ static void spu_bind_context(struct spu *spu, struct spu_context *ctx)
246 spu_switch_notify(spu, ctx); 246 spu_switch_notify(spu, ctx);
247 ctx->state = SPU_STATE_RUNNABLE; 247 ctx->state = SPU_STATE_RUNNABLE;
248 248
249 spuctx_switch_state(ctx, SPU_UTIL_IDLE_LOADED); 249 spuctx_switch_state(ctx, SPU_UTIL_USER);
250} 250}
251 251
252/* 252/*
diff --git a/arch/powerpc/platforms/cell/spufs/sputrace.c b/arch/powerpc/platforms/cell/spufs/sputrace.c
index 01974f7776e1..79aa773f3c99 100644
--- a/arch/powerpc/platforms/cell/spufs/sputrace.c
+++ b/arch/powerpc/platforms/cell/spufs/sputrace.c
@@ -58,12 +58,12 @@ static int sputrace_sprint(char *tbuf, int n)
58 ktime_to_timespec(ktime_sub(t->tstamp, sputrace_start)); 58 ktime_to_timespec(ktime_sub(t->tstamp, sputrace_start));
59 59
60 return snprintf(tbuf, n, 60 return snprintf(tbuf, n,
61 "[%lu.%09lu] %d: %s (thread = %d, spu = %d)\n", 61 "[%lu.%09lu] %d: %s (ctxthread = %d, spu = %d)\n",
62 (unsigned long) tv.tv_sec, 62 (unsigned long) tv.tv_sec,
63 (unsigned long) tv.tv_nsec, 63 (unsigned long) tv.tv_nsec,
64 t->owner_tid,
65 t->name,
66 t->curr_tid, 64 t->curr_tid,
65 t->name,
66 t->owner_tid,
67 t->number); 67 t->number);
68} 68}
69 69
@@ -188,6 +188,7 @@ struct spu_probe spu_probes[] = {
188 { "spufs_ps_nopfn__insert", "%p %p", spu_context_event }, 188 { "spufs_ps_nopfn__insert", "%p %p", spu_context_event },
189 { "spu_acquire_saved__enter", "%p", spu_context_nospu_event }, 189 { "spu_acquire_saved__enter", "%p", spu_context_nospu_event },
190 { "destroy_spu_context__enter", "%p", spu_context_nospu_event }, 190 { "destroy_spu_context__enter", "%p", spu_context_nospu_event },
191 { "spufs_stop_callback__enter", "%p %p", spu_context_event },
191}; 192};
192 193
193static int __init sputrace_init(void) 194static int __init sputrace_init(void)
diff --git a/arch/powerpc/platforms/cell/spufs/switch.c b/arch/powerpc/platforms/cell/spufs/switch.c
index 6f5886c7b1f9..e9dc7a55d1b9 100644
--- a/arch/powerpc/platforms/cell/spufs/switch.c
+++ b/arch/powerpc/platforms/cell/spufs/switch.c
@@ -34,6 +34,7 @@
34 34
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/errno.h> 36#include <linux/errno.h>
37#include <linux/hardirq.h>
37#include <linux/sched.h> 38#include <linux/sched.h>
38#include <linux/kernel.h> 39#include <linux/kernel.h>
39#include <linux/mm.h> 40#include <linux/mm.h>
@@ -117,6 +118,8 @@ static inline void disable_interrupts(struct spu_state *csa, struct spu *spu)
117 * Write INT_MASK_class1 with value of 0. 118 * Write INT_MASK_class1 with value of 0.
118 * Save INT_Mask_class2 in CSA. 119 * Save INT_Mask_class2 in CSA.
119 * Write INT_MASK_class2 with value of 0. 120 * Write INT_MASK_class2 with value of 0.
121 * Synchronize all three interrupts to be sure
122 * we no longer execute a handler on another CPU.
120 */ 123 */
121 spin_lock_irq(&spu->register_lock); 124 spin_lock_irq(&spu->register_lock);
122 if (csa) { 125 if (csa) {
@@ -129,6 +132,9 @@ static inline void disable_interrupts(struct spu_state *csa, struct spu *spu)
129 spu_int_mask_set(spu, 2, 0ul); 132 spu_int_mask_set(spu, 2, 0ul);
130 eieio(); 133 eieio();
131 spin_unlock_irq(&spu->register_lock); 134 spin_unlock_irq(&spu->register_lock);
135 synchronize_irq(spu->irqs[0]);
136 synchronize_irq(spu->irqs[1]);
137 synchronize_irq(spu->irqs[2]);
132} 138}
133 139
134static inline void set_watchdog_timer(struct spu_state *csa, struct spu *spu) 140static inline void set_watchdog_timer(struct spu_state *csa, struct spu *spu)
diff --git a/arch/powerpc/platforms/celleb/beat.h b/arch/powerpc/platforms/celleb/beat.h
index b2e292df13ca..ac82ac35b991 100644
--- a/arch/powerpc/platforms/celleb/beat.h
+++ b/arch/powerpc/platforms/celleb/beat.h
@@ -21,9 +21,6 @@
21#ifndef _CELLEB_BEAT_H 21#ifndef _CELLEB_BEAT_H
22#define _CELLEB_BEAT_H 22#define _CELLEB_BEAT_H
23 23
24#define DABRX_KERNEL (1UL<<1)
25#define DABRX_USER (1UL<<0)
26
27int64_t beat_get_term_char(uint64_t,uint64_t*,uint64_t*,uint64_t*); 24int64_t beat_get_term_char(uint64_t,uint64_t*,uint64_t*,uint64_t*);
28int64_t beat_put_term_char(uint64_t,uint64_t,uint64_t,uint64_t); 25int64_t beat_put_term_char(uint64_t,uint64_t,uint64_t,uint64_t);
29int64_t beat_repository_encode(int, const char *, uint64_t[4]); 26int64_t beat_repository_encode(int, const char *, uint64_t[4]);
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 7049294fb469..14e48b5a94ba 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -26,7 +26,6 @@ struct cpa_data {
26 pgprot_t mask_set; 26 pgprot_t mask_set;
27 pgprot_t mask_clr; 27 pgprot_t mask_clr;
28 int numpages; 28 int numpages;
29 int processed;
30 int flushtlb; 29 int flushtlb;
31 unsigned long pfn; 30 unsigned long pfn;
32}; 31};
@@ -291,8 +290,8 @@ try_preserve_large_page(pte_t *kpte, unsigned long address,
291 */ 290 */
292 nextpage_addr = (address + psize) & pmask; 291 nextpage_addr = (address + psize) & pmask;
293 numpages = (nextpage_addr - address) >> PAGE_SHIFT; 292 numpages = (nextpage_addr - address) >> PAGE_SHIFT;
294 if (numpages < cpa->processed) 293 if (numpages < cpa->numpages)
295 cpa->processed = numpages; 294 cpa->numpages = numpages;
296 295
297 /* 296 /*
298 * We are safe now. Check whether the new pgprot is the same: 297 * We are safe now. Check whether the new pgprot is the same:
@@ -319,7 +318,7 @@ try_preserve_large_page(pte_t *kpte, unsigned long address,
319 */ 318 */
320 addr = address + PAGE_SIZE; 319 addr = address + PAGE_SIZE;
321 pfn++; 320 pfn++;
322 for (i = 1; i < cpa->processed; i++, addr += PAGE_SIZE, pfn++) { 321 for (i = 1; i < cpa->numpages; i++, addr += PAGE_SIZE, pfn++) {
323 pgprot_t chk_prot = static_protections(new_prot, addr, pfn); 322 pgprot_t chk_prot = static_protections(new_prot, addr, pfn);
324 323
325 if (pgprot_val(chk_prot) != pgprot_val(new_prot)) 324 if (pgprot_val(chk_prot) != pgprot_val(new_prot))
@@ -343,7 +342,7 @@ try_preserve_large_page(pte_t *kpte, unsigned long address,
343 * that we limited the number of possible pages already to 342 * that we limited the number of possible pages already to
344 * the number of pages in the large page. 343 * the number of pages in the large page.
345 */ 344 */
346 if (address == (nextpage_addr - psize) && cpa->processed == numpages) { 345 if (address == (nextpage_addr - psize) && cpa->numpages == numpages) {
347 /* 346 /*
348 * The address is aligned and the number of pages 347 * The address is aligned and the number of pages
349 * covers the full page. 348 * covers the full page.
@@ -573,7 +572,7 @@ repeat:
573 set_pte_atomic(kpte, new_pte); 572 set_pte_atomic(kpte, new_pte);
574 cpa->flushtlb = 1; 573 cpa->flushtlb = 1;
575 } 574 }
576 cpa->processed = 1; 575 cpa->numpages = 1;
577 return 0; 576 return 0;
578 } 577 }
579 578
@@ -584,7 +583,7 @@ repeat:
584 do_split = try_preserve_large_page(kpte, address, cpa); 583 do_split = try_preserve_large_page(kpte, address, cpa);
585 /* 584 /*
586 * When the range fits into the existing large page, 585 * When the range fits into the existing large page,
587 * return. cp->processed and cpa->tlbflush have been updated in 586 * return. cp->numpages and cpa->tlbflush have been updated in
588 * try_large_page: 587 * try_large_page:
589 */ 588 */
590 if (do_split <= 0) 589 if (do_split <= 0)
@@ -663,7 +662,7 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias)
663 * Store the remaining nr of pages for the large page 662 * Store the remaining nr of pages for the large page
664 * preservation check. 663 * preservation check.
665 */ 664 */
666 cpa->numpages = cpa->processed = numpages; 665 cpa->numpages = numpages;
667 666
668 ret = __change_page_attr(cpa, checkalias); 667 ret = __change_page_attr(cpa, checkalias);
669 if (ret) 668 if (ret)
@@ -680,9 +679,9 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias)
680 * CPA operation. Either a large page has been 679 * CPA operation. Either a large page has been
681 * preserved or a single page update happened. 680 * preserved or a single page update happened.
682 */ 681 */
683 BUG_ON(cpa->processed > numpages); 682 BUG_ON(cpa->numpages > numpages);
684 numpages -= cpa->processed; 683 numpages -= cpa->numpages;
685 cpa->vaddr += cpa->processed * PAGE_SIZE; 684 cpa->vaddr += cpa->numpages * PAGE_SIZE;
686 } 685 }
687 return 0; 686 return 0;
688} 687}
diff --git a/block/blk-barrier.c b/block/blk-barrier.c
index 6901eedeffce..55c5f1fc4f1f 100644
--- a/block/blk-barrier.c
+++ b/block/blk-barrier.c
@@ -259,8 +259,11 @@ int blk_do_ordered(struct request_queue *q, struct request **rqp)
259 259
260static void bio_end_empty_barrier(struct bio *bio, int err) 260static void bio_end_empty_barrier(struct bio *bio, int err)
261{ 261{
262 if (err) 262 if (err) {
263 if (err == -EOPNOTSUPP)
264 set_bit(BIO_EOPNOTSUPP, &bio->bi_flags);
263 clear_bit(BIO_UPTODATE, &bio->bi_flags); 265 clear_bit(BIO_UPTODATE, &bio->bi_flags);
266 }
264 267
265 complete(bio->bi_private); 268 complete(bio->bi_private);
266} 269}
@@ -309,7 +312,9 @@ int blkdev_issue_flush(struct block_device *bdev, sector_t *error_sector)
309 *error_sector = bio->bi_sector; 312 *error_sector = bio->bi_sector;
310 313
311 ret = 0; 314 ret = 0;
312 if (!bio_flagged(bio, BIO_UPTODATE)) 315 if (bio_flagged(bio, BIO_EOPNOTSUPP))
316 ret = -EOPNOTSUPP;
317 else if (!bio_flagged(bio, BIO_UPTODATE))
313 ret = -EIO; 318 ret = -EIO;
314 319
315 bio_put(bio); 320 bio_put(bio);
diff --git a/block/blk-core.c b/block/blk-core.c
index 775c8516abf5..2a438a93f723 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -127,7 +127,6 @@ void rq_init(struct request_queue *q, struct request *rq)
127 rq->nr_hw_segments = 0; 127 rq->nr_hw_segments = 0;
128 rq->ioprio = 0; 128 rq->ioprio = 0;
129 rq->special = NULL; 129 rq->special = NULL;
130 rq->raw_data_len = 0;
131 rq->buffer = NULL; 130 rq->buffer = NULL;
132 rq->tag = -1; 131 rq->tag = -1;
133 rq->errors = 0; 132 rq->errors = 0;
@@ -135,6 +134,7 @@ void rq_init(struct request_queue *q, struct request *rq)
135 rq->cmd_len = 0; 134 rq->cmd_len = 0;
136 memset(rq->cmd, 0, sizeof(rq->cmd)); 135 memset(rq->cmd, 0, sizeof(rq->cmd));
137 rq->data_len = 0; 136 rq->data_len = 0;
137 rq->extra_len = 0;
138 rq->sense_len = 0; 138 rq->sense_len = 0;
139 rq->data = NULL; 139 rq->data = NULL;
140 rq->sense = NULL; 140 rq->sense = NULL;
@@ -424,7 +424,6 @@ void blk_put_queue(struct request_queue *q)
424{ 424{
425 kobject_put(&q->kobj); 425 kobject_put(&q->kobj);
426} 426}
427EXPORT_SYMBOL(blk_put_queue);
428 427
429void blk_cleanup_queue(struct request_queue *q) 428void blk_cleanup_queue(struct request_queue *q)
430{ 429{
@@ -592,7 +591,6 @@ int blk_get_queue(struct request_queue *q)
592 591
593 return 1; 592 return 1;
594} 593}
595EXPORT_SYMBOL(blk_get_queue);
596 594
597static inline void blk_free_request(struct request_queue *q, struct request *rq) 595static inline void blk_free_request(struct request_queue *q, struct request *rq)
598{ 596{
@@ -1768,6 +1766,7 @@ static inline void __end_request(struct request *rq, int uptodate,
1768 1766
1769/** 1767/**
1770 * blk_rq_bytes - Returns bytes left to complete in the entire request 1768 * blk_rq_bytes - Returns bytes left to complete in the entire request
1769 * @rq: the request being processed
1771 **/ 1770 **/
1772unsigned int blk_rq_bytes(struct request *rq) 1771unsigned int blk_rq_bytes(struct request *rq)
1773{ 1772{
@@ -1780,6 +1779,7 @@ EXPORT_SYMBOL_GPL(blk_rq_bytes);
1780 1779
1781/** 1780/**
1782 * blk_rq_cur_bytes - Returns bytes left to complete in the current segment 1781 * blk_rq_cur_bytes - Returns bytes left to complete in the current segment
1782 * @rq: the request being processed
1783 **/ 1783 **/
1784unsigned int blk_rq_cur_bytes(struct request *rq) 1784unsigned int blk_rq_cur_bytes(struct request *rq)
1785{ 1785{
@@ -2016,7 +2016,6 @@ void blk_rq_bio_prep(struct request_queue *q, struct request *rq,
2016 rq->hard_cur_sectors = rq->current_nr_sectors; 2016 rq->hard_cur_sectors = rq->current_nr_sectors;
2017 rq->hard_nr_sectors = rq->nr_sectors = bio_sectors(bio); 2017 rq->hard_nr_sectors = rq->nr_sectors = bio_sectors(bio);
2018 rq->buffer = bio_data(bio); 2018 rq->buffer = bio_data(bio);
2019 rq->raw_data_len = bio->bi_size;
2020 rq->data_len = bio->bi_size; 2019 rq->data_len = bio->bi_size;
2021 2020
2022 rq->bio = rq->biotail = bio; 2021 rq->bio = rq->biotail = bio;
diff --git a/block/blk-map.c b/block/blk-map.c
index 09f7fd0bcb73..c07d9c8317f4 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -19,7 +19,6 @@ int blk_rq_append_bio(struct request_queue *q, struct request *rq,
19 rq->biotail->bi_next = bio; 19 rq->biotail->bi_next = bio;
20 rq->biotail = bio; 20 rq->biotail = bio;
21 21
22 rq->raw_data_len += bio->bi_size;
23 rq->data_len += bio->bi_size; 22 rq->data_len += bio->bi_size;
24 } 23 }
25 return 0; 24 return 0;
@@ -44,6 +43,7 @@ static int __blk_rq_map_user(struct request_queue *q, struct request *rq,
44 void __user *ubuf, unsigned int len) 43 void __user *ubuf, unsigned int len)
45{ 44{
46 unsigned long uaddr; 45 unsigned long uaddr;
46 unsigned int alignment;
47 struct bio *bio, *orig_bio; 47 struct bio *bio, *orig_bio;
48 int reading, ret; 48 int reading, ret;
49 49
@@ -54,8 +54,8 @@ static int __blk_rq_map_user(struct request_queue *q, struct request *rq,
54 * direct dma. else, set up kernel bounce buffers 54 * direct dma. else, set up kernel bounce buffers
55 */ 55 */
56 uaddr = (unsigned long) ubuf; 56 uaddr = (unsigned long) ubuf;
57 if (!(uaddr & queue_dma_alignment(q)) && 57 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
58 !(len & queue_dma_alignment(q))) 58 if (!(uaddr & alignment) && !(len & alignment))
59 bio = bio_map_user(q, NULL, uaddr, len, reading); 59 bio = bio_map_user(q, NULL, uaddr, len, reading);
60 else 60 else
61 bio = bio_copy_user(q, uaddr, len, reading); 61 bio = bio_copy_user(q, uaddr, len, reading);
@@ -142,20 +142,22 @@ int blk_rq_map_user(struct request_queue *q, struct request *rq,
142 142
143 /* 143 /*
144 * __blk_rq_map_user() copies the buffers if starting address 144 * __blk_rq_map_user() copies the buffers if starting address
145 * or length isn't aligned. As the copied buffer is always 145 * or length isn't aligned to dma_pad_mask. As the copied
146 * page aligned, we know that there's enough room for padding. 146 * buffer is always page aligned, we know that there's enough
147 * Extend the last bio and update rq->data_len accordingly. 147 * room for padding. Extend the last bio and update
148 * rq->data_len accordingly.
148 * 149 *
149 * On unmap, bio_uncopy_user() will use unmodified 150 * On unmap, bio_uncopy_user() will use unmodified
150 * bio_map_data pointed to by bio->bi_private. 151 * bio_map_data pointed to by bio->bi_private.
151 */ 152 */
152 if (len & queue_dma_alignment(q)) { 153 if (len & q->dma_pad_mask) {
153 unsigned int pad_len = (queue_dma_alignment(q) & ~len) + 1; 154 unsigned int pad_len = (q->dma_pad_mask & ~len) + 1;
154 struct bio *bio = rq->biotail; 155 struct bio *tail = rq->biotail;
155 156
156 bio->bi_io_vec[bio->bi_vcnt - 1].bv_len += pad_len; 157 tail->bi_io_vec[tail->bi_vcnt - 1].bv_len += pad_len;
157 bio->bi_size += pad_len; 158 tail->bi_size += pad_len;
158 rq->data_len += pad_len; 159
160 rq->extra_len += pad_len;
159 } 161 }
160 162
161 rq->buffer = rq->data = NULL; 163 rq->buffer = rq->data = NULL;
@@ -215,7 +217,6 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
215 rq->buffer = rq->data = NULL; 217 rq->buffer = rq->data = NULL;
216 return 0; 218 return 0;
217} 219}
218EXPORT_SYMBOL(blk_rq_map_user_iov);
219 220
220/** 221/**
221 * blk_rq_unmap_user - unmap a request with user data 222 * blk_rq_unmap_user - unmap a request with user data
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 7506c4fe0264..0f58616bcd7f 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -231,7 +231,7 @@ new_segment:
231 ((unsigned long)q->dma_drain_buffer) & 231 ((unsigned long)q->dma_drain_buffer) &
232 (PAGE_SIZE - 1)); 232 (PAGE_SIZE - 1));
233 nsegs++; 233 nsegs++;
234 rq->data_len += q->dma_drain_size; 234 rq->extra_len += q->dma_drain_size;
235 } 235 }
236 236
237 if (sg) 237 if (sg)
diff --git a/block/blk-settings.c b/block/blk-settings.c
index 9a8ffdd0ce3d..1344a0ea5cc6 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -140,7 +140,7 @@ void blk_queue_bounce_limit(struct request_queue *q, u64 dma_addr)
140 /* Assume anything <= 4GB can be handled by IOMMU. 140 /* Assume anything <= 4GB can be handled by IOMMU.
141 Actually some IOMMUs can handle everything, but I don't 141 Actually some IOMMUs can handle everything, but I don't
142 know of a way to test this here. */ 142 know of a way to test this here. */
143 if (b_pfn < (min_t(u64, 0xffffffff, BLK_BOUNCE_HIGH) >> PAGE_SHIFT)) 143 if (b_pfn <= (min_t(u64, 0xffffffff, BLK_BOUNCE_HIGH) >> PAGE_SHIFT))
144 dma = 1; 144 dma = 1;
145 q->bounce_pfn = max_low_pfn; 145 q->bounce_pfn = max_low_pfn;
146#else 146#else
@@ -293,8 +293,24 @@ void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b)
293EXPORT_SYMBOL(blk_queue_stack_limits); 293EXPORT_SYMBOL(blk_queue_stack_limits);
294 294
295/** 295/**
296 * blk_queue_dma_drain - Set up a drain buffer for excess dma. 296 * blk_queue_dma_pad - set pad mask
297 * @q: the request queue for the device
298 * @mask: pad mask
299 *
300 * Set pad mask. Direct IO requests are padded to the mask specified.
297 * 301 *
302 * Appending pad buffer to a request modifies ->data_len such that it
303 * includes the pad buffer. The original requested data length can be
304 * obtained using blk_rq_raw_data_len().
305 **/
306void blk_queue_dma_pad(struct request_queue *q, unsigned int mask)
307{
308 q->dma_pad_mask = mask;
309}
310EXPORT_SYMBOL(blk_queue_dma_pad);
311
312/**
313 * blk_queue_dma_drain - Set up a drain buffer for excess dma.
298 * @q: the request queue for the device 314 * @q: the request queue for the device
299 * @dma_drain_needed: fn which returns non-zero if drain is necessary 315 * @dma_drain_needed: fn which returns non-zero if drain is necessary
300 * @buf: physically contiguous buffer 316 * @buf: physically contiguous buffer
@@ -316,7 +332,7 @@ EXPORT_SYMBOL(blk_queue_stack_limits);
316 * device can support otherwise there won't be room for the drain 332 * device can support otherwise there won't be room for the drain
317 * buffer. 333 * buffer.
318 */ 334 */
319extern int blk_queue_dma_drain(struct request_queue *q, 335int blk_queue_dma_drain(struct request_queue *q,
320 dma_drain_needed_fn *dma_drain_needed, 336 dma_drain_needed_fn *dma_drain_needed,
321 void *buf, unsigned int size) 337 void *buf, unsigned int size)
322{ 338{
diff --git a/block/blk-tag.c b/block/blk-tag.c
index a8c37d4bbb32..4780a46ce234 100644
--- a/block/blk-tag.c
+++ b/block/blk-tag.c
@@ -6,6 +6,8 @@
6#include <linux/bio.h> 6#include <linux/bio.h>
7#include <linux/blkdev.h> 7#include <linux/blkdev.h>
8 8
9#include "blk.h"
10
9/** 11/**
10 * blk_queue_find_tag - find a request by its tag and queue 12 * blk_queue_find_tag - find a request by its tag and queue
11 * @q: The request queue for the device 13 * @q: The request queue for the device
diff --git a/block/blk.h b/block/blk.h
index ec898dd0c65c..ec9120fb789a 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -32,6 +32,8 @@ void blk_recalc_rq_sectors(struct request *rq, int nsect);
32 32
33void blk_queue_congestion_threshold(struct request_queue *q); 33void blk_queue_congestion_threshold(struct request_queue *q);
34 34
35int blk_dev_init(void);
36
35/* 37/*
36 * Return the threshold (number of used requests) at which the queue is 38 * Return the threshold (number of used requests) at which the queue is
37 * considered to be congested. It include a little hysteresis to keep the 39 * considered to be congested. It include a little hysteresis to keep the
diff --git a/block/bsg.c b/block/bsg.c
index 7f3c09549e4b..8917c5174dc2 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -437,14 +437,14 @@ static int blk_complete_sgv4_hdr_rq(struct request *rq, struct sg_io_v4 *hdr,
437 } 437 }
438 438
439 if (rq->next_rq) { 439 if (rq->next_rq) {
440 hdr->dout_resid = rq->raw_data_len; 440 hdr->dout_resid = rq->data_len;
441 hdr->din_resid = rq->next_rq->raw_data_len; 441 hdr->din_resid = rq->next_rq->data_len;
442 blk_rq_unmap_user(bidi_bio); 442 blk_rq_unmap_user(bidi_bio);
443 blk_put_request(rq->next_rq); 443 blk_put_request(rq->next_rq);
444 } else if (rq_data_dir(rq) == READ) 444 } else if (rq_data_dir(rq) == READ)
445 hdr->din_resid = rq->raw_data_len; 445 hdr->din_resid = rq->data_len;
446 else 446 else
447 hdr->dout_resid = rq->raw_data_len; 447 hdr->dout_resid = rq->data_len;
448 448
449 /* 449 /*
450 * If the request generated a negative error number, return it 450 * If the request generated a negative error number, return it
diff --git a/block/genhd.c b/block/genhd.c
index 53f2238e69c8..c44527d16c52 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -17,11 +17,15 @@
17#include <linux/buffer_head.h> 17#include <linux/buffer_head.h>
18#include <linux/mutex.h> 18#include <linux/mutex.h>
19 19
20#include "blk.h"
21
20static DEFINE_MUTEX(block_class_lock); 22static DEFINE_MUTEX(block_class_lock);
21#ifndef CONFIG_SYSFS_DEPRECATED 23#ifndef CONFIG_SYSFS_DEPRECATED
22struct kobject *block_depr; 24struct kobject *block_depr;
23#endif 25#endif
24 26
27static struct device_type disk_type;
28
25/* 29/*
26 * Can be deleted altogether. Later. 30 * Can be deleted altogether. Later.
27 * 31 *
@@ -346,8 +350,6 @@ const struct seq_operations partitions_op = {
346#endif 350#endif
347 351
348 352
349extern int blk_dev_init(void);
350
351static struct kobject *base_probe(dev_t devt, int *part, void *data) 353static struct kobject *base_probe(dev_t devt, int *part, void *data)
352{ 354{
353 if (request_module("block-major-%d-%d", MAJOR(devt), MINOR(devt)) > 0) 355 if (request_module("block-major-%d-%d", MAJOR(devt), MINOR(devt)) > 0)
@@ -502,7 +504,7 @@ struct class block_class = {
502 .name = "block", 504 .name = "block",
503}; 505};
504 506
505struct device_type disk_type = { 507static struct device_type disk_type = {
506 .name = "disk", 508 .name = "disk",
507 .groups = disk_attr_groups, 509 .groups = disk_attr_groups,
508 .release = disk_release, 510 .release = disk_release,
@@ -632,12 +634,14 @@ static void media_change_notify_thread(struct work_struct *work)
632 put_device(gd->driverfs_dev); 634 put_device(gd->driverfs_dev);
633} 635}
634 636
637#if 0
635void genhd_media_change_notify(struct gendisk *disk) 638void genhd_media_change_notify(struct gendisk *disk)
636{ 639{
637 get_device(disk->driverfs_dev); 640 get_device(disk->driverfs_dev);
638 schedule_work(&disk->async_notify); 641 schedule_work(&disk->async_notify);
639} 642}
640EXPORT_SYMBOL_GPL(genhd_media_change_notify); 643EXPORT_SYMBOL_GPL(genhd_media_change_notify);
644#endif /* 0 */
641 645
642dev_t blk_lookup_devt(const char *name) 646dev_t blk_lookup_devt(const char *name)
643{ 647{
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index e993cac4911d..a2c3a936ebf9 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -266,7 +266,7 @@ static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr,
266 hdr->info = 0; 266 hdr->info = 0;
267 if (hdr->masked_status || hdr->host_status || hdr->driver_status) 267 if (hdr->masked_status || hdr->host_status || hdr->driver_status)
268 hdr->info |= SG_INFO_CHECK; 268 hdr->info |= SG_INFO_CHECK;
269 hdr->resid = rq->raw_data_len; 269 hdr->resid = rq->data_len;
270 hdr->sb_len_wr = 0; 270 hdr->sb_len_wr = 0;
271 271
272 if (rq->sense_len && hdr->sbp) { 272 if (rq->sense_len && hdr->sbp) {
@@ -528,8 +528,8 @@ static int __blk_send_generic(struct request_queue *q, struct gendisk *bd_disk,
528 rq = blk_get_request(q, WRITE, __GFP_WAIT); 528 rq = blk_get_request(q, WRITE, __GFP_WAIT);
529 rq->cmd_type = REQ_TYPE_BLOCK_PC; 529 rq->cmd_type = REQ_TYPE_BLOCK_PC;
530 rq->data = NULL; 530 rq->data = NULL;
531 rq->raw_data_len = 0;
532 rq->data_len = 0; 531 rq->data_len = 0;
532 rq->extra_len = 0;
533 rq->timeout = BLK_DEFAULT_SG_TIMEOUT; 533 rq->timeout = BLK_DEFAULT_SG_TIMEOUT;
534 memset(rq->cmd, 0, sizeof(rq->cmd)); 534 memset(rq->cmd, 0, sizeof(rq->cmd));
535 rq->cmd[0] = cmd; 535 rq->cmd[0] = cmd;
diff --git a/drivers/acorn/char/defkeymap-l7200.c b/drivers/acorn/char/defkeymap-l7200.c
index 28a5fbc6aa1a..93d80a1c36f9 100644
--- a/drivers/acorn/char/defkeymap-l7200.c
+++ b/drivers/acorn/char/defkeymap-l7200.c
@@ -347,40 +347,40 @@ char *func_table[MAX_NR_FUNC] = {
347}; 347};
348 348
349struct kbdiacruc accent_table[MAX_DIACR] = { 349struct kbdiacruc accent_table[MAX_DIACR] = {
350 {'`', 'A', '\300'}, {'`', 'a', '\340'}, 350 {'`', 'A', 0300}, {'`', 'a', 0340},
351 {'\'', 'A', '\301'}, {'\'', 'a', '\341'}, 351 {'\'', 'A', 0301}, {'\'', 'a', 0341},
352 {'^', 'A', '\302'}, {'^', 'a', '\342'}, 352 {'^', 'A', 0302}, {'^', 'a', 0342},
353 {'~', 'A', '\303'}, {'~', 'a', '\343'}, 353 {'~', 'A', 0303}, {'~', 'a', 0343},
354 {'"', 'A', '\304'}, {'"', 'a', '\344'}, 354 {'"', 'A', 0304}, {'"', 'a', 0344},
355 {'O', 'A', '\305'}, {'o', 'a', '\345'}, 355 {'O', 'A', 0305}, {'o', 'a', 0345},
356 {'0', 'A', '\305'}, {'0', 'a', '\345'}, 356 {'0', 'A', 0305}, {'0', 'a', 0345},
357 {'A', 'A', '\305'}, {'a', 'a', '\345'}, 357 {'A', 'A', 0305}, {'a', 'a', 0345},
358 {'A', 'E', '\306'}, {'a', 'e', '\346'}, 358 {'A', 'E', 0306}, {'a', 'e', 0346},
359 {',', 'C', '\307'}, {',', 'c', '\347'}, 359 {',', 'C', 0307}, {',', 'c', 0347},
360 {'`', 'E', '\310'}, {'`', 'e', '\350'}, 360 {'`', 'E', 0310}, {'`', 'e', 0350},
361 {'\'', 'E', '\311'}, {'\'', 'e', '\351'}, 361 {'\'', 'E', 0311}, {'\'', 'e', 0351},
362 {'^', 'E', '\312'}, {'^', 'e', '\352'}, 362 {'^', 'E', 0312}, {'^', 'e', 0352},
363 {'"', 'E', '\313'}, {'"', 'e', '\353'}, 363 {'"', 'E', 0313}, {'"', 'e', 0353},
364 {'`', 'I', '\314'}, {'`', 'i', '\354'}, 364 {'`', 'I', 0314}, {'`', 'i', 0354},
365 {'\'', 'I', '\315'}, {'\'', 'i', '\355'}, 365 {'\'', 'I', 0315}, {'\'', 'i', 0355},
366 {'^', 'I', '\316'}, {'^', 'i', '\356'}, 366 {'^', 'I', 0316}, {'^', 'i', 0356},
367 {'"', 'I', '\317'}, {'"', 'i', '\357'}, 367 {'"', 'I', 0317}, {'"', 'i', 0357},
368 {'-', 'D', '\320'}, {'-', 'd', '\360'}, 368 {'-', 'D', 0320}, {'-', 'd', 0360},
369 {'~', 'N', '\321'}, {'~', 'n', '\361'}, 369 {'~', 'N', 0321}, {'~', 'n', 0361},
370 {'`', 'O', '\322'}, {'`', 'o', '\362'}, 370 {'`', 'O', 0322}, {'`', 'o', 0362},
371 {'\'', 'O', '\323'}, {'\'', 'o', '\363'}, 371 {'\'', 'O', 0323}, {'\'', 'o', 0363},
372 {'^', 'O', '\324'}, {'^', 'o', '\364'}, 372 {'^', 'O', 0324}, {'^', 'o', 0364},
373 {'~', 'O', '\325'}, {'~', 'o', '\365'}, 373 {'~', 'O', 0325}, {'~', 'o', 0365},
374 {'"', 'O', '\326'}, {'"', 'o', '\366'}, 374 {'"', 'O', 0326}, {'"', 'o', 0366},
375 {'/', 'O', '\330'}, {'/', 'o', '\370'}, 375 {'/', 'O', 0330}, {'/', 'o', 0370},
376 {'`', 'U', '\331'}, {'`', 'u', '\371'}, 376 {'`', 'U', 0331}, {'`', 'u', 0371},
377 {'\'', 'U', '\332'}, {'\'', 'u', '\372'}, 377 {'\'', 'U', 0332}, {'\'', 'u', 0372},
378 {'^', 'U', '\333'}, {'^', 'u', '\373'}, 378 {'^', 'U', 0333}, {'^', 'u', 0373},
379 {'"', 'U', '\334'}, {'"', 'u', '\374'}, 379 {'"', 'U', 0334}, {'"', 'u', 0374},
380 {'\'', 'Y', '\335'}, {'\'', 'y', '\375'}, 380 {'\'', 'Y', 0335}, {'\'', 'y', 0375},
381 {'T', 'H', '\336'}, {'t', 'h', '\376'}, 381 {'T', 'H', 0336}, {'t', 'h', 0376},
382 {'s', 's', '\337'}, {'"', 'y', '\377'}, 382 {'s', 's', 0337}, {'"', 'y', 0377},
383 {'s', 'z', '\337'}, {'i', 'j', '\377'}, 383 {'s', 'z', 0337}, {'i', 'j', 0377},
384}; 384};
385 385
386unsigned int accent_table_size = 68; 386unsigned int accent_table_size = 68;
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 7b1f1ee8131d..8f0e8f2bc628 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -862,9 +862,10 @@ static int ata_scsi_dev_config(struct scsi_device *sdev,
862 struct request_queue *q = sdev->request_queue; 862 struct request_queue *q = sdev->request_queue;
863 void *buf; 863 void *buf;
864 864
865 /* set the min alignment */ 865 /* set the min alignment and padding */
866 blk_queue_update_dma_alignment(sdev->request_queue, 866 blk_queue_update_dma_alignment(sdev->request_queue,
867 ATA_DMA_PAD_SZ - 1); 867 ATA_DMA_PAD_SZ - 1);
868 blk_queue_dma_pad(sdev->request_queue, ATA_DMA_PAD_SZ - 1);
868 869
869 /* configure draining */ 870 /* configure draining */
870 buf = kmalloc(ATAPI_MAX_DRAIN, q->bounce_gfp | GFP_KERNEL); 871 buf = kmalloc(ATAPI_MAX_DRAIN, q->bounce_gfp | GFP_KERNEL);
@@ -2538,7 +2539,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc)
2538 } 2539 }
2539 2540
2540 qc->tf.command = ATA_CMD_PACKET; 2541 qc->tf.command = ATA_CMD_PACKET;
2541 qc->nbytes = scsi_bufflen(scmd); 2542 qc->nbytes = scsi_bufflen(scmd) + scmd->request->extra_len;
2542 2543
2543 /* check whether ATAPI DMA is safe */ 2544 /* check whether ATAPI DMA is safe */
2544 if (!using_pio && ata_check_atapi_dma(qc)) 2545 if (!using_pio && ata_check_atapi_dma(qc))
@@ -2549,7 +2550,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc)
2549 * want to set it properly, and for DMA where it is 2550 * want to set it properly, and for DMA where it is
2550 * effectively meaningless. 2551 * effectively meaningless.
2551 */ 2552 */
2552 nbytes = min(scmd->request->raw_data_len, (unsigned int)63 * 1024); 2553 nbytes = min(scmd->request->data_len, (unsigned int)63 * 1024);
2553 2554
2554 /* Most ATAPI devices which honor transfer chunk size don't 2555 /* Most ATAPI devices which honor transfer chunk size don't
2555 * behave according to the spec when odd chunk size which 2556 * behave according to the spec when odd chunk size which
@@ -2875,7 +2876,7 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
2875 * TODO: find out if we need to do more here to 2876 * TODO: find out if we need to do more here to
2876 * cover scatter/gather case. 2877 * cover scatter/gather case.
2877 */ 2878 */
2878 qc->nbytes = scsi_bufflen(scmd); 2879 qc->nbytes = scsi_bufflen(scmd) + scmd->request->extra_len;
2879 2880
2880 /* request result TF and be quiet about device error */ 2881 /* request result TF and be quiet about device error */
2881 qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET; 2882 qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET;
diff --git a/drivers/base/transport_class.c b/drivers/base/transport_class.c
index f25e7c6b2d27..40bca48abc12 100644
--- a/drivers/base/transport_class.c
+++ b/drivers/base/transport_class.c
@@ -126,9 +126,7 @@ static int transport_setup_classdev(struct attribute_container *cont,
126} 126}
127 127
128/** 128/**
129 * transport_setup_device - declare a new dev for transport class association 129 * transport_setup_device - declare a new dev for transport class association but don't make it visible yet.
130 * but don't make it visible yet.
131 *
132 * @dev: the generic device representing the entity being added 130 * @dev: the generic device representing the entity being added
133 * 131 *
134 * Usually, dev represents some component in the HBA system (either 132 * Usually, dev represents some component in the HBA system (either
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 9715be3f2487..55bd35c0f082 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -33,6 +33,7 @@
33#include <linux/blkpg.h> 33#include <linux/blkpg.h>
34#include <linux/timer.h> 34#include <linux/timer.h>
35#include <linux/proc_fs.h> 35#include <linux/proc_fs.h>
36#include <linux/seq_file.h>
36#include <linux/init.h> 37#include <linux/init.h>
37#include <linux/hdreg.h> 38#include <linux/hdreg.h>
38#include <linux/spinlock.h> 39#include <linux/spinlock.h>
@@ -131,7 +132,6 @@ static struct board_type products[] = {
131/*define how many times we will try a command because of bus resets */ 132/*define how many times we will try a command because of bus resets */
132#define MAX_CMD_RETRIES 3 133#define MAX_CMD_RETRIES 3
133 134
134#define READ_AHEAD 1024
135#define MAX_CTLR 32 135#define MAX_CTLR 32
136 136
137/* Originally cciss driver only supports 8 major numbers */ 137/* Originally cciss driver only supports 8 major numbers */
@@ -174,8 +174,6 @@ static int sendcmd_withirq(__u8 cmd, int ctlr, void *buff, size_t size,
174static void fail_all_cmds(unsigned long ctlr); 174static void fail_all_cmds(unsigned long ctlr);
175 175
176#ifdef CONFIG_PROC_FS 176#ifdef CONFIG_PROC_FS
177static int cciss_proc_get_info(char *buffer, char **start, off_t offset,
178 int length, int *eof, void *data);
179static void cciss_procinit(int i); 177static void cciss_procinit(int i);
180#else 178#else
181static void cciss_procinit(int i) 179static void cciss_procinit(int i)
@@ -240,24 +238,46 @@ static inline CommandList_struct *removeQ(CommandList_struct **Qptr,
240 */ 238 */
241#define ENG_GIG 1000000000 239#define ENG_GIG 1000000000
242#define ENG_GIG_FACTOR (ENG_GIG/512) 240#define ENG_GIG_FACTOR (ENG_GIG/512)
241#define ENGAGE_SCSI "engage scsi"
243static const char *raid_label[] = { "0", "4", "1(1+0)", "5", "5+1", "ADG", 242static const char *raid_label[] = { "0", "4", "1(1+0)", "5", "5+1", "ADG",
244 "UNKNOWN" 243 "UNKNOWN"
245}; 244};
246 245
247static struct proc_dir_entry *proc_cciss; 246static struct proc_dir_entry *proc_cciss;
248 247
249static int cciss_proc_get_info(char *buffer, char **start, off_t offset, 248static void cciss_seq_show_header(struct seq_file *seq)
250 int length, int *eof, void *data)
251{ 249{
252 off_t pos = 0; 250 ctlr_info_t *h = seq->private;
253 off_t len = 0; 251
254 int size, i, ctlr; 252 seq_printf(seq, "%s: HP %s Controller\n"
255 ctlr_info_t *h = (ctlr_info_t *) data; 253 "Board ID: 0x%08lx\n"
256 drive_info_struct *drv; 254 "Firmware Version: %c%c%c%c\n"
257 unsigned long flags; 255 "IRQ: %d\n"
258 sector_t vol_sz, vol_sz_frac; 256 "Logical drives: %d\n"
257 "Current Q depth: %d\n"
258 "Current # commands on controller: %d\n"
259 "Max Q depth since init: %d\n"
260 "Max # commands on controller since init: %d\n"
261 "Max SG entries since init: %d\n",
262 h->devname,
263 h->product_name,
264 (unsigned long)h->board_id,
265 h->firm_ver[0], h->firm_ver[1], h->firm_ver[2],
266 h->firm_ver[3], (unsigned int)h->intr[SIMPLE_MODE_INT],
267 h->num_luns,
268 h->Qdepth, h->commands_outstanding,
269 h->maxQsinceinit, h->max_outstanding, h->maxSG);
259 270
260 ctlr = h->ctlr; 271#ifdef CONFIG_CISS_SCSI_TAPE
272 cciss_seq_tape_report(seq, h->ctlr);
273#endif /* CONFIG_CISS_SCSI_TAPE */
274}
275
276static void *cciss_seq_start(struct seq_file *seq, loff_t *pos)
277{
278 ctlr_info_t *h = seq->private;
279 unsigned ctlr = h->ctlr;
280 unsigned long flags;
261 281
262 /* prevent displaying bogus info during configuration 282 /* prevent displaying bogus info during configuration
263 * or deconfiguration of a logical volume 283 * or deconfiguration of a logical volume
@@ -265,115 +285,155 @@ static int cciss_proc_get_info(char *buffer, char **start, off_t offset,
265 spin_lock_irqsave(CCISS_LOCK(ctlr), flags); 285 spin_lock_irqsave(CCISS_LOCK(ctlr), flags);
266 if (h->busy_configuring) { 286 if (h->busy_configuring) {
267 spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); 287 spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
268 return -EBUSY; 288 return ERR_PTR(-EBUSY);
269 } 289 }
270 h->busy_configuring = 1; 290 h->busy_configuring = 1;
271 spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); 291 spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
272 292
273 size = sprintf(buffer, "%s: HP %s Controller\n" 293 if (*pos == 0)
274 "Board ID: 0x%08lx\n" 294 cciss_seq_show_header(seq);
275 "Firmware Version: %c%c%c%c\n"
276 "IRQ: %d\n"
277 "Logical drives: %d\n"
278 "Max sectors: %d\n"
279 "Current Q depth: %d\n"
280 "Current # commands on controller: %d\n"
281 "Max Q depth since init: %d\n"
282 "Max # commands on controller since init: %d\n"
283 "Max SG entries since init: %d\n\n",
284 h->devname,
285 h->product_name,
286 (unsigned long)h->board_id,
287 h->firm_ver[0], h->firm_ver[1], h->firm_ver[2],
288 h->firm_ver[3], (unsigned int)h->intr[SIMPLE_MODE_INT],
289 h->num_luns,
290 h->cciss_max_sectors,
291 h->Qdepth, h->commands_outstanding,
292 h->maxQsinceinit, h->max_outstanding, h->maxSG);
293
294 pos += size;
295 len += size;
296 cciss_proc_tape_report(ctlr, buffer, &pos, &len);
297 for (i = 0; i <= h->highest_lun; i++) {
298
299 drv = &h->drv[i];
300 if (drv->heads == 0)
301 continue;
302 295
303 vol_sz = drv->nr_blocks; 296 return pos;
304 vol_sz_frac = sector_div(vol_sz, ENG_GIG_FACTOR); 297}
305 vol_sz_frac *= 100; 298
306 sector_div(vol_sz_frac, ENG_GIG_FACTOR); 299static int cciss_seq_show(struct seq_file *seq, void *v)
300{
301 sector_t vol_sz, vol_sz_frac;
302 ctlr_info_t *h = seq->private;
303 unsigned ctlr = h->ctlr;
304 loff_t *pos = v;
305 drive_info_struct *drv = &h->drv[*pos];
306
307 if (*pos > h->highest_lun)
308 return 0;
309
310 if (drv->heads == 0)
311 return 0;
312
313 vol_sz = drv->nr_blocks;
314 vol_sz_frac = sector_div(vol_sz, ENG_GIG_FACTOR);
315 vol_sz_frac *= 100;
316 sector_div(vol_sz_frac, ENG_GIG_FACTOR);
317
318 if (drv->raid_level > 5)
319 drv->raid_level = RAID_UNKNOWN;
320 seq_printf(seq, "cciss/c%dd%d:"
321 "\t%4u.%02uGB\tRAID %s\n",
322 ctlr, (int) *pos, (int)vol_sz, (int)vol_sz_frac,
323 raid_label[drv->raid_level]);
324 return 0;
325}
326
327static void *cciss_seq_next(struct seq_file *seq, void *v, loff_t *pos)
328{
329 ctlr_info_t *h = seq->private;
330
331 if (*pos > h->highest_lun)
332 return NULL;
333 *pos += 1;
334
335 return pos;
336}
337
338static void cciss_seq_stop(struct seq_file *seq, void *v)
339{
340 ctlr_info_t *h = seq->private;
341
342 /* Only reset h->busy_configuring if we succeeded in setting
343 * it during cciss_seq_start. */
344 if (v == ERR_PTR(-EBUSY))
345 return;
307 346
308 if (drv->raid_level > 5)
309 drv->raid_level = RAID_UNKNOWN;
310 size = sprintf(buffer + len, "cciss/c%dd%d:"
311 "\t%4u.%02uGB\tRAID %s\n",
312 ctlr, i, (int)vol_sz, (int)vol_sz_frac,
313 raid_label[drv->raid_level]);
314 pos += size;
315 len += size;
316 }
317
318 *eof = 1;
319 *start = buffer + offset;
320 len -= offset;
321 if (len > length)
322 len = length;
323 h->busy_configuring = 0; 347 h->busy_configuring = 0;
324 return len;
325} 348}
326 349
327static int 350static struct seq_operations cciss_seq_ops = {
328cciss_proc_write(struct file *file, const char __user *buffer, 351 .start = cciss_seq_start,
329 unsigned long count, void *data) 352 .show = cciss_seq_show,
353 .next = cciss_seq_next,
354 .stop = cciss_seq_stop,
355};
356
357static int cciss_seq_open(struct inode *inode, struct file *file)
330{ 358{
331 unsigned char cmd[80]; 359 int ret = seq_open(file, &cciss_seq_ops);
332 int len; 360 struct seq_file *seq = file->private_data;
333#ifdef CONFIG_CISS_SCSI_TAPE 361
334 ctlr_info_t *h = (ctlr_info_t *) data; 362 if (!ret)
335 int rc; 363 seq->private = PDE(inode)->data;
364
365 return ret;
366}
367
368static ssize_t
369cciss_proc_write(struct file *file, const char __user *buf,
370 size_t length, loff_t *ppos)
371{
372 int err;
373 char *buffer;
374
375#ifndef CONFIG_CISS_SCSI_TAPE
376 return -EINVAL;
336#endif 377#endif
337 378
338 if (count > sizeof(cmd) - 1) 379 if (!buf || length > PAGE_SIZE - 1)
339 return -EINVAL; 380 return -EINVAL;
340 if (copy_from_user(cmd, buffer, count)) 381
341 return -EFAULT; 382 buffer = (char *)__get_free_page(GFP_KERNEL);
342 cmd[count] = '\0'; 383 if (!buffer)
343 len = strlen(cmd); // above 3 lines ensure safety 384 return -ENOMEM;
344 if (len && cmd[len - 1] == '\n') 385
345 cmd[--len] = '\0'; 386 err = -EFAULT;
346# ifdef CONFIG_CISS_SCSI_TAPE 387 if (copy_from_user(buffer, buf, length))
347 if (strcmp("engage scsi", cmd) == 0) { 388 goto out;
389 buffer[length] = '\0';
390
391#ifdef CONFIG_CISS_SCSI_TAPE
392 if (strncmp(ENGAGE_SCSI, buffer, sizeof ENGAGE_SCSI - 1) == 0) {
393 struct seq_file *seq = file->private_data;
394 ctlr_info_t *h = seq->private;
395 int rc;
396
348 rc = cciss_engage_scsi(h->ctlr); 397 rc = cciss_engage_scsi(h->ctlr);
349 if (rc != 0) 398 if (rc != 0)
350 return -rc; 399 err = -rc;
351 return count; 400 else
352 } 401 err = length;
402 } else
403#endif /* CONFIG_CISS_SCSI_TAPE */
404 err = -EINVAL;
353 /* might be nice to have "disengage" too, but it's not 405 /* might be nice to have "disengage" too, but it's not
354 safely possible. (only 1 module use count, lock issues.) */ 406 safely possible. (only 1 module use count, lock issues.) */
355# endif 407
356 return -EINVAL; 408out:
409 free_page((unsigned long)buffer);
410 return err;
357} 411}
358 412
359/* 413static struct file_operations cciss_proc_fops = {
360 * Get us a file in /proc/cciss that says something about each controller. 414 .owner = THIS_MODULE,
361 * Create /proc/cciss if it doesn't exist yet. 415 .open = cciss_seq_open,
362 */ 416 .read = seq_read,
417 .llseek = seq_lseek,
418 .release = seq_release,
419 .write = cciss_proc_write,
420};
421
363static void __devinit cciss_procinit(int i) 422static void __devinit cciss_procinit(int i)
364{ 423{
365 struct proc_dir_entry *pde; 424 struct proc_dir_entry *pde;
366 425
367 if (proc_cciss == NULL) { 426 if (proc_cciss == NULL)
368 proc_cciss = proc_mkdir("cciss", proc_root_driver); 427 proc_cciss = proc_mkdir("cciss", proc_root_driver);
369 if (!proc_cciss) 428 if (!proc_cciss)
370 return; 429 return;
371 } 430 pde = proc_create(hba[i]->devname, S_IWUSR | S_IRUSR | S_IRGRP |
431 S_IROTH, proc_cciss,
432 &cciss_proc_fops);
433 if (!pde)
434 return;
372 435
373 pde = create_proc_read_entry(hba[i]->devname, 436 pde->data = hba[i];
374 S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH,
375 proc_cciss, cciss_proc_get_info, hba[i]);
376 pde->write_proc = cciss_proc_write;
377} 437}
378#endif /* CONFIG_PROC_FS */ 438#endif /* CONFIG_PROC_FS */
379 439
@@ -1341,7 +1401,6 @@ geo_inq:
1341 disk->private_data = &h->drv[drv_index]; 1401 disk->private_data = &h->drv[drv_index];
1342 1402
1343 /* Set up queue information */ 1403 /* Set up queue information */
1344 disk->queue->backing_dev_info.ra_pages = READ_AHEAD;
1345 blk_queue_bounce_limit(disk->queue, hba[ctlr]->pdev->dma_mask); 1404 blk_queue_bounce_limit(disk->queue, hba[ctlr]->pdev->dma_mask);
1346 1405
1347 /* This is a hardware imposed limit. */ 1406 /* This is a hardware imposed limit. */
@@ -3434,7 +3493,6 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3434 } 3493 }
3435 drv->queue = q; 3494 drv->queue = q;
3436 3495
3437 q->backing_dev_info.ra_pages = READ_AHEAD;
3438 blk_queue_bounce_limit(q, hba[i]->pdev->dma_mask); 3496 blk_queue_bounce_limit(q, hba[i]->pdev->dma_mask);
3439 3497
3440 /* This is a hardware imposed limit. */ 3498 /* This is a hardware imposed limit. */
diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
index 55178e9973a0..45ac09300eb3 100644
--- a/drivers/block/cciss_scsi.c
+++ b/drivers/block/cciss_scsi.c
@@ -1404,21 +1404,18 @@ cciss_engage_scsi(int ctlr)
1404} 1404}
1405 1405
1406static void 1406static void
1407cciss_proc_tape_report(int ctlr, unsigned char *buffer, off_t *pos, off_t *len) 1407cciss_seq_tape_report(struct seq_file *seq, int ctlr)
1408{ 1408{
1409 unsigned long flags; 1409 unsigned long flags;
1410 int size;
1411
1412 *pos = *pos -1; *len = *len - 1; // cut off the last trailing newline
1413 1410
1414 CPQ_TAPE_LOCK(ctlr, flags); 1411 CPQ_TAPE_LOCK(ctlr, flags);
1415 size = sprintf(buffer + *len, 1412 seq_printf(seq,
1416 "Sequential access devices: %d\n\n", 1413 "Sequential access devices: %d\n\n",
1417 ccissscsi[ctlr].ndevices); 1414 ccissscsi[ctlr].ndevices);
1418 CPQ_TAPE_UNLOCK(ctlr, flags); 1415 CPQ_TAPE_UNLOCK(ctlr, flags);
1419 *pos += size; *len += size;
1420} 1416}
1421 1417
1418
1422/* Need at least one of these error handlers to keep ../scsi/hosts.c from 1419/* Need at least one of these error handlers to keep ../scsi/hosts.c from
1423 * complaining. Doing a host- or bus-reset can't do anything good here. 1420 * complaining. Doing a host- or bus-reset can't do anything good here.
1424 * Despite what it might say in scsi_error.c, there may well be commands 1421 * Despite what it might say in scsi_error.c, there may well be commands
@@ -1498,6 +1495,5 @@ static int cciss_eh_abort_handler(struct scsi_cmnd *scsicmd)
1498#define cciss_scsi_setup(cntl_num) 1495#define cciss_scsi_setup(cntl_num)
1499#define cciss_unregister_scsi(ctlr) 1496#define cciss_unregister_scsi(ctlr)
1500#define cciss_register_scsi(ctlr) 1497#define cciss_register_scsi(ctlr)
1501#define cciss_proc_tape_report(ctlr, buffer, pos, len)
1502 1498
1503#endif /* CONFIG_CISS_SCSI_TAPE */ 1499#endif /* CONFIG_CISS_SCSI_TAPE */
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index db259e60289b..12f5baea439b 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -1152,8 +1152,8 @@ clean_up_and_return:
1152/* This code is similar to that in open_for_data. The routine is called 1152/* This code is similar to that in open_for_data. The routine is called
1153 whenever an audio play operation is requested. 1153 whenever an audio play operation is requested.
1154*/ 1154*/
1155int check_for_audio_disc(struct cdrom_device_info * cdi, 1155static int check_for_audio_disc(struct cdrom_device_info * cdi,
1156 struct cdrom_device_ops * cdo) 1156 struct cdrom_device_ops * cdo)
1157{ 1157{
1158 int ret; 1158 int ret;
1159 tracktype tracks; 1159 tracktype tracks;
diff --git a/drivers/char/defkeymap.c_shipped b/drivers/char/defkeymap.c_shipped
index 0aa419a61767..d2208dfe3f67 100644
--- a/drivers/char/defkeymap.c_shipped
+++ b/drivers/char/defkeymap.c_shipped
@@ -223,40 +223,40 @@ char *func_table[MAX_NR_FUNC] = {
223}; 223};
224 224
225struct kbdiacruc accent_table[MAX_DIACR] = { 225struct kbdiacruc accent_table[MAX_DIACR] = {
226 {'`', 'A', '\300'}, {'`', 'a', '\340'}, 226 {'`', 'A', 0300}, {'`', 'a', 0340},
227 {'\'', 'A', '\301'}, {'\'', 'a', '\341'}, 227 {'\'', 'A', 0301}, {'\'', 'a', 0341},
228 {'^', 'A', '\302'}, {'^', 'a', '\342'}, 228 {'^', 'A', 0302}, {'^', 'a', 0342},
229 {'~', 'A', '\303'}, {'~', 'a', '\343'}, 229 {'~', 'A', 0303}, {'~', 'a', 0343},
230 {'"', 'A', '\304'}, {'"', 'a', '\344'}, 230 {'"', 'A', 0304}, {'"', 'a', 0344},
231 {'O', 'A', '\305'}, {'o', 'a', '\345'}, 231 {'O', 'A', 0305}, {'o', 'a', 0345},
232 {'0', 'A', '\305'}, {'0', 'a', '\345'}, 232 {'0', 'A', 0305}, {'0', 'a', 0345},
233 {'A', 'A', '\305'}, {'a', 'a', '\345'}, 233 {'A', 'A', 0305}, {'a', 'a', 0345},
234 {'A', 'E', '\306'}, {'a', 'e', '\346'}, 234 {'A', 'E', 0306}, {'a', 'e', 0346},
235 {',', 'C', '\307'}, {',', 'c', '\347'}, 235 {',', 'C', 0307}, {',', 'c', 0347},
236 {'`', 'E', '\310'}, {'`', 'e', '\350'}, 236 {'`', 'E', 0310}, {'`', 'e', 0350},
237 {'\'', 'E', '\311'}, {'\'', 'e', '\351'}, 237 {'\'', 'E', 0311}, {'\'', 'e', 0351},
238 {'^', 'E', '\312'}, {'^', 'e', '\352'}, 238 {'^', 'E', 0312}, {'^', 'e', 0352},
239 {'"', 'E', '\313'}, {'"', 'e', '\353'}, 239 {'"', 'E', 0313}, {'"', 'e', 0353},
240 {'`', 'I', '\314'}, {'`', 'i', '\354'}, 240 {'`', 'I', 0314}, {'`', 'i', 0354},
241 {'\'', 'I', '\315'}, {'\'', 'i', '\355'}, 241 {'\'', 'I', 0315}, {'\'', 'i', 0355},
242 {'^', 'I', '\316'}, {'^', 'i', '\356'}, 242 {'^', 'I', 0316}, {'^', 'i', 0356},
243 {'"', 'I', '\317'}, {'"', 'i', '\357'}, 243 {'"', 'I', 0317}, {'"', 'i', 0357},
244 {'-', 'D', '\320'}, {'-', 'd', '\360'}, 244 {'-', 'D', 0320}, {'-', 'd', 0360},
245 {'~', 'N', '\321'}, {'~', 'n', '\361'}, 245 {'~', 'N', 0321}, {'~', 'n', 0361},
246 {'`', 'O', '\322'}, {'`', 'o', '\362'}, 246 {'`', 'O', 0322}, {'`', 'o', 0362},
247 {'\'', 'O', '\323'}, {'\'', 'o', '\363'}, 247 {'\'', 'O', 0323}, {'\'', 'o', 0363},
248 {'^', 'O', '\324'}, {'^', 'o', '\364'}, 248 {'^', 'O', 0324}, {'^', 'o', 0364},
249 {'~', 'O', '\325'}, {'~', 'o', '\365'}, 249 {'~', 'O', 0325}, {'~', 'o', 0365},
250 {'"', 'O', '\326'}, {'"', 'o', '\366'}, 250 {'"', 'O', 0326}, {'"', 'o', 0366},
251 {'/', 'O', '\330'}, {'/', 'o', '\370'}, 251 {'/', 'O', 0330}, {'/', 'o', 0370},
252 {'`', 'U', '\331'}, {'`', 'u', '\371'}, 252 {'`', 'U', 0331}, {'`', 'u', 0371},
253 {'\'', 'U', '\332'}, {'\'', 'u', '\372'}, 253 {'\'', 'U', 0332}, {'\'', 'u', 0372},
254 {'^', 'U', '\333'}, {'^', 'u', '\373'}, 254 {'^', 'U', 0333}, {'^', 'u', 0373},
255 {'"', 'U', '\334'}, {'"', 'u', '\374'}, 255 {'"', 'U', 0334}, {'"', 'u', 0374},
256 {'\'', 'Y', '\335'}, {'\'', 'y', '\375'}, 256 {'\'', 'Y', 0335}, {'\'', 'y', 0375},
257 {'T', 'H', '\336'}, {'t', 'h', '\376'}, 257 {'T', 'H', 0336}, {'t', 'h', 0376},
258 {'s', 's', '\337'}, {'"', 'y', '\377'}, 258 {'s', 's', 0337}, {'"', 'y', 0377},
259 {'s', 'z', '\337'}, {'i', 'j', '\377'}, 259 {'s', 'z', 0337}, {'i', 'j', 0377},
260}; 260};
261 261
262unsigned int accent_table_size = 68; 262unsigned int accent_table_size = 68;
diff --git a/drivers/char/xilinx_hwicap/buffer_icap.c b/drivers/char/xilinx_hwicap/buffer_icap.c
index dfea2bde162b..f577daedb630 100644
--- a/drivers/char/xilinx_hwicap/buffer_icap.c
+++ b/drivers/char/xilinx_hwicap/buffer_icap.c
@@ -73,8 +73,8 @@
73#define XHI_BUFFER_START 0 73#define XHI_BUFFER_START 0
74 74
75/** 75/**
76 * buffer_icap_get_status: Get the contents of the status register. 76 * buffer_icap_get_status - Get the contents of the status register.
77 * @parameter base_address: is the base address of the device 77 * @base_address: is the base address of the device
78 * 78 *
79 * The status register contains the ICAP status and the done bit. 79 * The status register contains the ICAP status and the done bit.
80 * 80 *
@@ -94,9 +94,9 @@ static inline u32 buffer_icap_get_status(void __iomem *base_address)
94} 94}
95 95
96/** 96/**
97 * buffer_icap_get_bram: Reads data from the storage buffer bram. 97 * buffer_icap_get_bram - Reads data from the storage buffer bram.
98 * @parameter base_address: contains the base address of the component. 98 * @base_address: contains the base address of the component.
99 * @parameter offset: The word offset from which the data should be read. 99 * @offset: The word offset from which the data should be read.
100 * 100 *
101 * A bram is used as a configuration memory cache. One frame of data can 101 * A bram is used as a configuration memory cache. One frame of data can
102 * be stored in this "storage buffer". 102 * be stored in this "storage buffer".
@@ -108,8 +108,8 @@ static inline u32 buffer_icap_get_bram(void __iomem *base_address,
108} 108}
109 109
110/** 110/**
111 * buffer_icap_busy: Return true if the icap device is busy 111 * buffer_icap_busy - Return true if the icap device is busy
112 * @parameter base_address: is the base address of the device 112 * @base_address: is the base address of the device
113 * 113 *
114 * The queries the low order bit of the status register, which 114 * The queries the low order bit of the status register, which
115 * indicates whether the current configuration or readback operation 115 * indicates whether the current configuration or readback operation
@@ -121,8 +121,8 @@ static inline bool buffer_icap_busy(void __iomem *base_address)
121} 121}
122 122
123/** 123/**
124 * buffer_icap_busy: Return true if the icap device is not busy 124 * buffer_icap_busy - Return true if the icap device is not busy
125 * @parameter base_address: is the base address of the device 125 * @base_address: is the base address of the device
126 * 126 *
127 * The queries the low order bit of the status register, which 127 * The queries the low order bit of the status register, which
128 * indicates whether the current configuration or readback operation 128 * indicates whether the current configuration or readback operation
@@ -134,9 +134,9 @@ static inline bool buffer_icap_done(void __iomem *base_address)
134} 134}
135 135
136/** 136/**
137 * buffer_icap_set_size: Set the size register. 137 * buffer_icap_set_size - Set the size register.
138 * @parameter base_address: is the base address of the device 138 * @base_address: is the base address of the device
139 * @parameter data: The size in bytes. 139 * @data: The size in bytes.
140 * 140 *
141 * The size register holds the number of 8 bit bytes to transfer between 141 * The size register holds the number of 8 bit bytes to transfer between
142 * bram and the icap (or icap to bram). 142 * bram and the icap (or icap to bram).
@@ -148,9 +148,9 @@ static inline void buffer_icap_set_size(void __iomem *base_address,
148} 148}
149 149
150/** 150/**
151 * buffer_icap_mSetoffsetReg: Set the bram offset register. 151 * buffer_icap_set_offset - Set the bram offset register.
152 * @parameter base_address: contains the base address of the device. 152 * @base_address: contains the base address of the device.
153 * @parameter data: is the value to be written to the data register. 153 * @data: is the value to be written to the data register.
154 * 154 *
155 * The bram offset register holds the starting bram address to transfer 155 * The bram offset register holds the starting bram address to transfer
156 * data from during configuration or write data to during readback. 156 * data from during configuration or write data to during readback.
@@ -162,9 +162,9 @@ static inline void buffer_icap_set_offset(void __iomem *base_address,
162} 162}
163 163
164/** 164/**
165 * buffer_icap_set_rnc: Set the RNC (Readback not Configure) register. 165 * buffer_icap_set_rnc - Set the RNC (Readback not Configure) register.
166 * @parameter base_address: contains the base address of the device. 166 * @base_address: contains the base address of the device.
167 * @parameter data: is the value to be written to the data register. 167 * @data: is the value to be written to the data register.
168 * 168 *
169 * The RNC register determines the direction of the data transfer. It 169 * The RNC register determines the direction of the data transfer. It
170 * controls whether a configuration or readback take place. Writing to 170 * controls whether a configuration or readback take place. Writing to
@@ -178,10 +178,10 @@ static inline void buffer_icap_set_rnc(void __iomem *base_address,
178} 178}
179 179
180/** 180/**
181 * buffer_icap_set_bram: Write data to the storage buffer bram. 181 * buffer_icap_set_bram - Write data to the storage buffer bram.
182 * @parameter base_address: contains the base address of the component. 182 * @base_address: contains the base address of the component.
183 * @parameter offset: The word offset at which the data should be written. 183 * @offset: The word offset at which the data should be written.
184 * @parameter data: The value to be written to the bram offset. 184 * @data: The value to be written to the bram offset.
185 * 185 *
186 * A bram is used as a configuration memory cache. One frame of data can 186 * A bram is used as a configuration memory cache. One frame of data can
187 * be stored in this "storage buffer". 187 * be stored in this "storage buffer".
@@ -193,10 +193,10 @@ static inline void buffer_icap_set_bram(void __iomem *base_address,
193} 193}
194 194
195/** 195/**
196 * buffer_icap_device_read: Transfer bytes from ICAP to the storage buffer. 196 * buffer_icap_device_read - Transfer bytes from ICAP to the storage buffer.
197 * @parameter drvdata: a pointer to the drvdata. 197 * @drvdata: a pointer to the drvdata.
198 * @parameter offset: The storage buffer start address. 198 * @offset: The storage buffer start address.
199 * @parameter count: The number of words (32 bit) to read from the 199 * @count: The number of words (32 bit) to read from the
200 * device (ICAP). 200 * device (ICAP).
201 **/ 201 **/
202static int buffer_icap_device_read(struct hwicap_drvdata *drvdata, 202static int buffer_icap_device_read(struct hwicap_drvdata *drvdata,
@@ -227,10 +227,10 @@ static int buffer_icap_device_read(struct hwicap_drvdata *drvdata,
227}; 227};
228 228
229/** 229/**
230 * buffer_icap_device_write: Transfer bytes from ICAP to the storage buffer. 230 * buffer_icap_device_write - Transfer bytes from ICAP to the storage buffer.
231 * @parameter drvdata: a pointer to the drvdata. 231 * @drvdata: a pointer to the drvdata.
232 * @parameter offset: The storage buffer start address. 232 * @offset: The storage buffer start address.
233 * @parameter count: The number of words (32 bit) to read from the 233 * @count: The number of words (32 bit) to read from the
234 * device (ICAP). 234 * device (ICAP).
235 **/ 235 **/
236static int buffer_icap_device_write(struct hwicap_drvdata *drvdata, 236static int buffer_icap_device_write(struct hwicap_drvdata *drvdata,
@@ -261,8 +261,8 @@ static int buffer_icap_device_write(struct hwicap_drvdata *drvdata,
261}; 261};
262 262
263/** 263/**
264 * buffer_icap_reset: Reset the logic of the icap device. 264 * buffer_icap_reset - Reset the logic of the icap device.
265 * @parameter drvdata: a pointer to the drvdata. 265 * @drvdata: a pointer to the drvdata.
266 * 266 *
267 * Writing to the status register resets the ICAP logic in an internal 267 * Writing to the status register resets the ICAP logic in an internal
268 * version of the core. For the version of the core published in EDK, 268 * version of the core. For the version of the core published in EDK,
@@ -274,10 +274,10 @@ void buffer_icap_reset(struct hwicap_drvdata *drvdata)
274} 274}
275 275
276/** 276/**
277 * buffer_icap_set_configuration: Load a partial bitstream from system memory. 277 * buffer_icap_set_configuration - Load a partial bitstream from system memory.
278 * @parameter drvdata: a pointer to the drvdata. 278 * @drvdata: a pointer to the drvdata.
279 * @parameter data: Kernel address of the partial bitstream. 279 * @data: Kernel address of the partial bitstream.
280 * @parameter size: the size of the partial bitstream in 32 bit words. 280 * @size: the size of the partial bitstream in 32 bit words.
281 **/ 281 **/
282int buffer_icap_set_configuration(struct hwicap_drvdata *drvdata, u32 *data, 282int buffer_icap_set_configuration(struct hwicap_drvdata *drvdata, u32 *data,
283 u32 size) 283 u32 size)
@@ -333,10 +333,10 @@ int buffer_icap_set_configuration(struct hwicap_drvdata *drvdata, u32 *data,
333}; 333};
334 334
335/** 335/**
336 * buffer_icap_get_configuration: Read configuration data from the device. 336 * buffer_icap_get_configuration - Read configuration data from the device.
337 * @parameter drvdata: a pointer to the drvdata. 337 * @drvdata: a pointer to the drvdata.
338 * @parameter data: Address of the data representing the partial bitstream 338 * @data: Address of the data representing the partial bitstream
339 * @parameter size: the size of the partial bitstream in 32 bit words. 339 * @size: the size of the partial bitstream in 32 bit words.
340 **/ 340 **/
341int buffer_icap_get_configuration(struct hwicap_drvdata *drvdata, u32 *data, 341int buffer_icap_get_configuration(struct hwicap_drvdata *drvdata, u32 *data,
342 u32 size) 342 u32 size)
diff --git a/drivers/char/xilinx_hwicap/fifo_icap.c b/drivers/char/xilinx_hwicap/fifo_icap.c
index 0988314694a6..6f45dbd47125 100644
--- a/drivers/char/xilinx_hwicap/fifo_icap.c
+++ b/drivers/char/xilinx_hwicap/fifo_icap.c
@@ -94,9 +94,9 @@
94 94
95 95
96/** 96/**
97 * fifo_icap_fifo_write: Write data to the write FIFO. 97 * fifo_icap_fifo_write - Write data to the write FIFO.
98 * @parameter drvdata: a pointer to the drvdata. 98 * @drvdata: a pointer to the drvdata.
99 * @parameter data: the 32-bit value to be written to the FIFO. 99 * @data: the 32-bit value to be written to the FIFO.
100 * 100 *
101 * This function will silently fail if the fifo is full. 101 * This function will silently fail if the fifo is full.
102 **/ 102 **/
@@ -108,8 +108,8 @@ static inline void fifo_icap_fifo_write(struct hwicap_drvdata *drvdata,
108} 108}
109 109
110/** 110/**
111 * fifo_icap_fifo_read: Read data from the Read FIFO. 111 * fifo_icap_fifo_read - Read data from the Read FIFO.
112 * @parameter drvdata: a pointer to the drvdata. 112 * @drvdata: a pointer to the drvdata.
113 * 113 *
114 * This function will silently fail if the fifo is empty. 114 * This function will silently fail if the fifo is empty.
115 **/ 115 **/
@@ -121,9 +121,9 @@ static inline u32 fifo_icap_fifo_read(struct hwicap_drvdata *drvdata)
121} 121}
122 122
123/** 123/**
124 * fifo_icap_set_read_size: Set the the size register. 124 * fifo_icap_set_read_size - Set the the size register.
125 * @parameter drvdata: a pointer to the drvdata. 125 * @drvdata: a pointer to the drvdata.
126 * @parameter data: the size of the following read transaction, in words. 126 * @data: the size of the following read transaction, in words.
127 **/ 127 **/
128static inline void fifo_icap_set_read_size(struct hwicap_drvdata *drvdata, 128static inline void fifo_icap_set_read_size(struct hwicap_drvdata *drvdata,
129 u32 data) 129 u32 data)
@@ -132,8 +132,8 @@ static inline void fifo_icap_set_read_size(struct hwicap_drvdata *drvdata,
132} 132}
133 133
134/** 134/**
135 * fifo_icap_start_config: Initiate a configuration (write) to the device. 135 * fifo_icap_start_config - Initiate a configuration (write) to the device.
136 * @parameter drvdata: a pointer to the drvdata. 136 * @drvdata: a pointer to the drvdata.
137 **/ 137 **/
138static inline void fifo_icap_start_config(struct hwicap_drvdata *drvdata) 138static inline void fifo_icap_start_config(struct hwicap_drvdata *drvdata)
139{ 139{
@@ -142,8 +142,8 @@ static inline void fifo_icap_start_config(struct hwicap_drvdata *drvdata)
142} 142}
143 143
144/** 144/**
145 * fifo_icap_start_readback: Initiate a readback from the device. 145 * fifo_icap_start_readback - Initiate a readback from the device.
146 * @parameter drvdata: a pointer to the drvdata. 146 * @drvdata: a pointer to the drvdata.
147 **/ 147 **/
148static inline void fifo_icap_start_readback(struct hwicap_drvdata *drvdata) 148static inline void fifo_icap_start_readback(struct hwicap_drvdata *drvdata)
149{ 149{
@@ -152,8 +152,8 @@ static inline void fifo_icap_start_readback(struct hwicap_drvdata *drvdata)
152} 152}
153 153
154/** 154/**
155 * fifo_icap_busy: Return true if the ICAP is still processing a transaction. 155 * fifo_icap_busy - Return true if the ICAP is still processing a transaction.
156 * @parameter drvdata: a pointer to the drvdata. 156 * @drvdata: a pointer to the drvdata.
157 **/ 157 **/
158static inline u32 fifo_icap_busy(struct hwicap_drvdata *drvdata) 158static inline u32 fifo_icap_busy(struct hwicap_drvdata *drvdata)
159{ 159{
@@ -163,8 +163,8 @@ static inline u32 fifo_icap_busy(struct hwicap_drvdata *drvdata)
163} 163}
164 164
165/** 165/**
166 * fifo_icap_write_fifo_vacancy: Query the write fifo available space. 166 * fifo_icap_write_fifo_vacancy - Query the write fifo available space.
167 * @parameter drvdata: a pointer to the drvdata. 167 * @drvdata: a pointer to the drvdata.
168 * 168 *
169 * Return the number of words that can be safely pushed into the write fifo. 169 * Return the number of words that can be safely pushed into the write fifo.
170 **/ 170 **/
@@ -175,8 +175,8 @@ static inline u32 fifo_icap_write_fifo_vacancy(
175} 175}
176 176
177/** 177/**
178 * fifo_icap_read_fifo_occupancy: Query the read fifo available data. 178 * fifo_icap_read_fifo_occupancy - Query the read fifo available data.
179 * @parameter drvdata: a pointer to the drvdata. 179 * @drvdata: a pointer to the drvdata.
180 * 180 *
181 * Return the number of words that can be safely read from the read fifo. 181 * Return the number of words that can be safely read from the read fifo.
182 **/ 182 **/
@@ -187,11 +187,11 @@ static inline u32 fifo_icap_read_fifo_occupancy(
187} 187}
188 188
189/** 189/**
190 * fifo_icap_set_configuration: Send configuration data to the ICAP. 190 * fifo_icap_set_configuration - Send configuration data to the ICAP.
191 * @parameter drvdata: a pointer to the drvdata. 191 * @drvdata: a pointer to the drvdata.
192 * @parameter frame_buffer: a pointer to the data to be written to the 192 * @frame_buffer: a pointer to the data to be written to the
193 * ICAP device. 193 * ICAP device.
194 * @parameter num_words: the number of words (32 bit) to write to the ICAP 194 * @num_words: the number of words (32 bit) to write to the ICAP
195 * device. 195 * device.
196 196
197 * This function writes the given user data to the Write FIFO in 197 * This function writes the given user data to the Write FIFO in
@@ -266,10 +266,10 @@ int fifo_icap_set_configuration(struct hwicap_drvdata *drvdata,
266} 266}
267 267
268/** 268/**
269 * fifo_icap_get_configuration: Read configuration data from the device. 269 * fifo_icap_get_configuration - Read configuration data from the device.
270 * @parameter drvdata: a pointer to the drvdata. 270 * @drvdata: a pointer to the drvdata.
271 * @parameter data: Address of the data representing the partial bitstream 271 * @data: Address of the data representing the partial bitstream
272 * @parameter size: the size of the partial bitstream in 32 bit words. 272 * @size: the size of the partial bitstream in 32 bit words.
273 * 273 *
274 * This function reads the specified number of words from the ICAP device in 274 * This function reads the specified number of words from the ICAP device in
275 * the polled mode. 275 * the polled mode.
@@ -335,8 +335,8 @@ int fifo_icap_get_configuration(struct hwicap_drvdata *drvdata,
335} 335}
336 336
337/** 337/**
338 * buffer_icap_reset: Reset the logic of the icap device. 338 * buffer_icap_reset - Reset the logic of the icap device.
339 * @parameter drvdata: a pointer to the drvdata. 339 * @drvdata: a pointer to the drvdata.
340 * 340 *
341 * This function forces the software reset of the complete HWICAP device. 341 * This function forces the software reset of the complete HWICAP device.
342 * All the registers will return to the default value and the FIFO is also 342 * All the registers will return to the default value and the FIFO is also
@@ -360,8 +360,8 @@ void fifo_icap_reset(struct hwicap_drvdata *drvdata)
360} 360}
361 361
362/** 362/**
363 * fifo_icap_flush_fifo: This function flushes the FIFOs in the device. 363 * fifo_icap_flush_fifo - This function flushes the FIFOs in the device.
364 * @parameter drvdata: a pointer to the drvdata. 364 * @drvdata: a pointer to the drvdata.
365 */ 365 */
366void fifo_icap_flush_fifo(struct hwicap_drvdata *drvdata) 366void fifo_icap_flush_fifo(struct hwicap_drvdata *drvdata)
367{ 367{
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
index 24f6aef0fd3c..2284fa2a5a57 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
@@ -84,7 +84,7 @@
84#include <linux/init.h> 84#include <linux/init.h>
85#include <linux/poll.h> 85#include <linux/poll.h>
86#include <linux/proc_fs.h> 86#include <linux/proc_fs.h>
87#include <asm/semaphore.h> 87#include <linux/mutex.h>
88#include <linux/sysctl.h> 88#include <linux/sysctl.h>
89#include <linux/version.h> 89#include <linux/version.h>
90#include <linux/fs.h> 90#include <linux/fs.h>
@@ -119,6 +119,7 @@ module_param(xhwicap_minor, int, S_IRUGO);
119 119
120/* An array, which is set to true when the device is registered. */ 120/* An array, which is set to true when the device is registered. */
121static bool probed_devices[HWICAP_DEVICES]; 121static bool probed_devices[HWICAP_DEVICES];
122static struct mutex icap_sem;
122 123
123static struct class *icap_class; 124static struct class *icap_class;
124 125
@@ -199,14 +200,14 @@ static const struct config_registers v5_config_registers = {
199}; 200};
200 201
201/** 202/**
202 * hwicap_command_desync: Send a DESYNC command to the ICAP port. 203 * hwicap_command_desync - Send a DESYNC command to the ICAP port.
203 * @parameter drvdata: a pointer to the drvdata. 204 * @drvdata: a pointer to the drvdata.
204 * 205 *
205 * This command desynchronizes the ICAP After this command, a 206 * This command desynchronizes the ICAP After this command, a
206 * bitstream containing a NULL packet, followed by a SYNCH packet is 207 * bitstream containing a NULL packet, followed by a SYNCH packet is
207 * required before the ICAP will recognize commands. 208 * required before the ICAP will recognize commands.
208 */ 209 */
209int hwicap_command_desync(struct hwicap_drvdata *drvdata) 210static int hwicap_command_desync(struct hwicap_drvdata *drvdata)
210{ 211{
211 u32 buffer[4]; 212 u32 buffer[4];
212 u32 index = 0; 213 u32 index = 0;
@@ -228,51 +229,18 @@ int hwicap_command_desync(struct hwicap_drvdata *drvdata)
228} 229}
229 230
230/** 231/**
231 * hwicap_command_capture: Send a CAPTURE command to the ICAP port. 232 * hwicap_get_configuration_register - Query a configuration register.
232 * @parameter drvdata: a pointer to the drvdata. 233 * @drvdata: a pointer to the drvdata.
233 * 234 * @reg: a constant which represents the configuration
234 * This command captures all of the flip flop states so they will be
235 * available during readback. One can use this command instead of
236 * enabling the CAPTURE block in the design.
237 */
238int hwicap_command_capture(struct hwicap_drvdata *drvdata)
239{
240 u32 buffer[7];
241 u32 index = 0;
242
243 /*
244 * Create the data to be written to the ICAP.
245 */
246 buffer[index++] = XHI_DUMMY_PACKET;
247 buffer[index++] = XHI_SYNC_PACKET;
248 buffer[index++] = XHI_NOOP_PACKET;
249 buffer[index++] = hwicap_type_1_write(drvdata->config_regs->CMD) | 1;
250 buffer[index++] = XHI_CMD_GCAPTURE;
251 buffer[index++] = XHI_DUMMY_PACKET;
252 buffer[index++] = XHI_DUMMY_PACKET;
253
254 /*
255 * Write the data to the FIFO and intiate the transfer of data
256 * present in the FIFO to the ICAP device.
257 */
258 return drvdata->config->set_configuration(drvdata,
259 &buffer[0], index);
260
261}
262
263/**
264 * hwicap_get_configuration_register: Query a configuration register.
265 * @parameter drvdata: a pointer to the drvdata.
266 * @parameter reg: a constant which represents the configuration
267 * register value to be returned. 235 * register value to be returned.
268 * Examples: XHI_IDCODE, XHI_FLR. 236 * Examples: XHI_IDCODE, XHI_FLR.
269 * @parameter RegData: returns the value of the register. 237 * @reg_data: returns the value of the register.
270 * 238 *
271 * Sends a query packet to the ICAP and then receives the response. 239 * Sends a query packet to the ICAP and then receives the response.
272 * The icap is left in Synched state. 240 * The icap is left in Synched state.
273 */ 241 */
274int hwicap_get_configuration_register(struct hwicap_drvdata *drvdata, 242static int hwicap_get_configuration_register(struct hwicap_drvdata *drvdata,
275 u32 reg, u32 *RegData) 243 u32 reg, u32 *reg_data)
276{ 244{
277 int status; 245 int status;
278 u32 buffer[6]; 246 u32 buffer[6];
@@ -300,14 +268,14 @@ int hwicap_get_configuration_register(struct hwicap_drvdata *drvdata,
300 /* 268 /*
301 * Read the configuration register 269 * Read the configuration register
302 */ 270 */
303 status = drvdata->config->get_configuration(drvdata, RegData, 1); 271 status = drvdata->config->get_configuration(drvdata, reg_data, 1);
304 if (status) 272 if (status)
305 return status; 273 return status;
306 274
307 return 0; 275 return 0;
308} 276}
309 277
310int hwicap_initialize_hwicap(struct hwicap_drvdata *drvdata) 278static int hwicap_initialize_hwicap(struct hwicap_drvdata *drvdata)
311{ 279{
312 int status; 280 int status;
313 u32 idcode; 281 u32 idcode;
@@ -344,7 +312,7 @@ int hwicap_initialize_hwicap(struct hwicap_drvdata *drvdata)
344} 312}
345 313
346static ssize_t 314static ssize_t
347hwicap_read(struct file *file, char *buf, size_t count, loff_t *ppos) 315hwicap_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
348{ 316{
349 struct hwicap_drvdata *drvdata = file->private_data; 317 struct hwicap_drvdata *drvdata = file->private_data;
350 ssize_t bytes_to_read = 0; 318 ssize_t bytes_to_read = 0;
@@ -353,8 +321,9 @@ hwicap_read(struct file *file, char *buf, size_t count, loff_t *ppos)
353 u32 bytes_remaining; 321 u32 bytes_remaining;
354 int status; 322 int status;
355 323
356 if (down_interruptible(&drvdata->sem)) 324 status = mutex_lock_interruptible(&drvdata->sem);
357 return -ERESTARTSYS; 325 if (status)
326 return status;
358 327
359 if (drvdata->read_buffer_in_use) { 328 if (drvdata->read_buffer_in_use) {
360 /* If there are leftover bytes in the buffer, just */ 329 /* If there are leftover bytes in the buffer, just */
@@ -370,8 +339,9 @@ hwicap_read(struct file *file, char *buf, size_t count, loff_t *ppos)
370 goto error; 339 goto error;
371 } 340 }
372 drvdata->read_buffer_in_use -= bytes_to_read; 341 drvdata->read_buffer_in_use -= bytes_to_read;
373 memcpy(drvdata->read_buffer + bytes_to_read, 342 memmove(drvdata->read_buffer,
374 drvdata->read_buffer, 4 - bytes_to_read); 343 drvdata->read_buffer + bytes_to_read,
344 4 - bytes_to_read);
375 } else { 345 } else {
376 /* Get new data from the ICAP, and return was was requested. */ 346 /* Get new data from the ICAP, and return was was requested. */
377 kbuf = (u32 *) get_zeroed_page(GFP_KERNEL); 347 kbuf = (u32 *) get_zeroed_page(GFP_KERNEL);
@@ -414,18 +384,20 @@ hwicap_read(struct file *file, char *buf, size_t count, loff_t *ppos)
414 status = -EFAULT; 384 status = -EFAULT;
415 goto error; 385 goto error;
416 } 386 }
417 memcpy(kbuf, drvdata->read_buffer, bytes_remaining); 387 memcpy(drvdata->read_buffer,
388 kbuf,
389 bytes_remaining);
418 drvdata->read_buffer_in_use = bytes_remaining; 390 drvdata->read_buffer_in_use = bytes_remaining;
419 free_page((unsigned long)kbuf); 391 free_page((unsigned long)kbuf);
420 } 392 }
421 status = bytes_to_read; 393 status = bytes_to_read;
422 error: 394 error:
423 up(&drvdata->sem); 395 mutex_unlock(&drvdata->sem);
424 return status; 396 return status;
425} 397}
426 398
427static ssize_t 399static ssize_t
428hwicap_write(struct file *file, const char *buf, 400hwicap_write(struct file *file, const char __user *buf,
429 size_t count, loff_t *ppos) 401 size_t count, loff_t *ppos)
430{ 402{
431 struct hwicap_drvdata *drvdata = file->private_data; 403 struct hwicap_drvdata *drvdata = file->private_data;
@@ -435,8 +407,9 @@ hwicap_write(struct file *file, const char *buf,
435 ssize_t len; 407 ssize_t len;
436 ssize_t status; 408 ssize_t status;
437 409
438 if (down_interruptible(&drvdata->sem)) 410 status = mutex_lock_interruptible(&drvdata->sem);
439 return -ERESTARTSYS; 411 if (status)
412 return status;
440 413
441 left += drvdata->write_buffer_in_use; 414 left += drvdata->write_buffer_in_use;
442 415
@@ -465,7 +438,7 @@ hwicap_write(struct file *file, const char *buf,
465 memcpy(kbuf, drvdata->write_buffer, 438 memcpy(kbuf, drvdata->write_buffer,
466 drvdata->write_buffer_in_use); 439 drvdata->write_buffer_in_use);
467 if (copy_from_user( 440 if (copy_from_user(
468 (((char *)kbuf) + (drvdata->write_buffer_in_use)), 441 (((char *)kbuf) + drvdata->write_buffer_in_use),
469 buf + written, 442 buf + written,
470 len - (drvdata->write_buffer_in_use))) { 443 len - (drvdata->write_buffer_in_use))) {
471 free_page((unsigned long)kbuf); 444 free_page((unsigned long)kbuf);
@@ -508,7 +481,7 @@ hwicap_write(struct file *file, const char *buf,
508 free_page((unsigned long)kbuf); 481 free_page((unsigned long)kbuf);
509 status = written; 482 status = written;
510 error: 483 error:
511 up(&drvdata->sem); 484 mutex_unlock(&drvdata->sem);
512 return status; 485 return status;
513} 486}
514 487
@@ -519,8 +492,9 @@ static int hwicap_open(struct inode *inode, struct file *file)
519 492
520 drvdata = container_of(inode->i_cdev, struct hwicap_drvdata, cdev); 493 drvdata = container_of(inode->i_cdev, struct hwicap_drvdata, cdev);
521 494
522 if (down_interruptible(&drvdata->sem)) 495 status = mutex_lock_interruptible(&drvdata->sem);
523 return -ERESTARTSYS; 496 if (status)
497 return status;
524 498
525 if (drvdata->is_open) { 499 if (drvdata->is_open) {
526 status = -EBUSY; 500 status = -EBUSY;
@@ -539,7 +513,7 @@ static int hwicap_open(struct inode *inode, struct file *file)
539 drvdata->is_open = 1; 513 drvdata->is_open = 1;
540 514
541 error: 515 error:
542 up(&drvdata->sem); 516 mutex_unlock(&drvdata->sem);
543 return status; 517 return status;
544} 518}
545 519
@@ -549,8 +523,7 @@ static int hwicap_release(struct inode *inode, struct file *file)
549 int i; 523 int i;
550 int status = 0; 524 int status = 0;
551 525
552 if (down_interruptible(&drvdata->sem)) 526 mutex_lock(&drvdata->sem);
553 return -ERESTARTSYS;
554 527
555 if (drvdata->write_buffer_in_use) { 528 if (drvdata->write_buffer_in_use) {
556 /* Flush write buffer. */ 529 /* Flush write buffer. */
@@ -569,7 +542,7 @@ static int hwicap_release(struct inode *inode, struct file *file)
569 542
570 error: 543 error:
571 drvdata->is_open = 0; 544 drvdata->is_open = 0;
572 up(&drvdata->sem); 545 mutex_unlock(&drvdata->sem);
573 return status; 546 return status;
574} 547}
575 548
@@ -592,31 +565,36 @@ static int __devinit hwicap_setup(struct device *dev, int id,
592 565
593 dev_info(dev, "Xilinx icap port driver\n"); 566 dev_info(dev, "Xilinx icap port driver\n");
594 567
568 mutex_lock(&icap_sem);
569
595 if (id < 0) { 570 if (id < 0) {
596 for (id = 0; id < HWICAP_DEVICES; id++) 571 for (id = 0; id < HWICAP_DEVICES; id++)
597 if (!probed_devices[id]) 572 if (!probed_devices[id])
598 break; 573 break;
599 } 574 }
600 if (id < 0 || id >= HWICAP_DEVICES) { 575 if (id < 0 || id >= HWICAP_DEVICES) {
576 mutex_unlock(&icap_sem);
601 dev_err(dev, "%s%i too large\n", DRIVER_NAME, id); 577 dev_err(dev, "%s%i too large\n", DRIVER_NAME, id);
602 return -EINVAL; 578 return -EINVAL;
603 } 579 }
604 if (probed_devices[id]) { 580 if (probed_devices[id]) {
581 mutex_unlock(&icap_sem);
605 dev_err(dev, "cannot assign to %s%i; it is already in use\n", 582 dev_err(dev, "cannot assign to %s%i; it is already in use\n",
606 DRIVER_NAME, id); 583 DRIVER_NAME, id);
607 return -EBUSY; 584 return -EBUSY;
608 } 585 }
609 586
610 probed_devices[id] = 1; 587 probed_devices[id] = 1;
588 mutex_unlock(&icap_sem);
611 589
612 devt = MKDEV(xhwicap_major, xhwicap_minor + id); 590 devt = MKDEV(xhwicap_major, xhwicap_minor + id);
613 591
614 drvdata = kmalloc(sizeof(struct hwicap_drvdata), GFP_KERNEL); 592 drvdata = kzalloc(sizeof(struct hwicap_drvdata), GFP_KERNEL);
615 if (!drvdata) { 593 if (!drvdata) {
616 dev_err(dev, "Couldn't allocate device private record\n"); 594 dev_err(dev, "Couldn't allocate device private record\n");
617 return -ENOMEM; 595 retval = -ENOMEM;
596 goto failed0;
618 } 597 }
619 memset((void *)drvdata, 0, sizeof(struct hwicap_drvdata));
620 dev_set_drvdata(dev, (void *)drvdata); 598 dev_set_drvdata(dev, (void *)drvdata);
621 599
622 if (!regs_res) { 600 if (!regs_res) {
@@ -648,7 +626,7 @@ static int __devinit hwicap_setup(struct device *dev, int id,
648 drvdata->config = config; 626 drvdata->config = config;
649 drvdata->config_regs = config_regs; 627 drvdata->config_regs = config_regs;
650 628
651 init_MUTEX(&drvdata->sem); 629 mutex_init(&drvdata->sem);
652 drvdata->is_open = 0; 630 drvdata->is_open = 0;
653 631
654 dev_info(dev, "ioremap %lx to %p with size %x\n", 632 dev_info(dev, "ioremap %lx to %p with size %x\n",
@@ -663,7 +641,7 @@ static int __devinit hwicap_setup(struct device *dev, int id,
663 goto failed3; 641 goto failed3;
664 } 642 }
665 /* devfs_mk_cdev(devt, S_IFCHR|S_IRUGO|S_IWUGO, DRIVER_NAME); */ 643 /* devfs_mk_cdev(devt, S_IFCHR|S_IRUGO|S_IWUGO, DRIVER_NAME); */
666 class_device_create(icap_class, NULL, devt, NULL, DRIVER_NAME); 644 device_create(icap_class, dev, devt, "%s%d", DRIVER_NAME, id);
667 return 0; /* success */ 645 return 0; /* success */
668 646
669 failed3: 647 failed3:
@@ -675,6 +653,11 @@ static int __devinit hwicap_setup(struct device *dev, int id,
675 failed1: 653 failed1:
676 kfree(drvdata); 654 kfree(drvdata);
677 655
656 failed0:
657 mutex_lock(&icap_sem);
658 probed_devices[id] = 0;
659 mutex_unlock(&icap_sem);
660
678 return retval; 661 return retval;
679} 662}
680 663
@@ -699,14 +682,16 @@ static int __devexit hwicap_remove(struct device *dev)
699 if (!drvdata) 682 if (!drvdata)
700 return 0; 683 return 0;
701 684
702 class_device_destroy(icap_class, drvdata->devt); 685 device_destroy(icap_class, drvdata->devt);
703 cdev_del(&drvdata->cdev); 686 cdev_del(&drvdata->cdev);
704 iounmap(drvdata->base_address); 687 iounmap(drvdata->base_address);
705 release_mem_region(drvdata->mem_start, drvdata->mem_size); 688 release_mem_region(drvdata->mem_start, drvdata->mem_size);
706 kfree(drvdata); 689 kfree(drvdata);
707 dev_set_drvdata(dev, NULL); 690 dev_set_drvdata(dev, NULL);
708 probed_devices[MINOR(dev->devt)-xhwicap_minor] = 0;
709 691
692 mutex_lock(&icap_sem);
693 probed_devices[MINOR(dev->devt)-xhwicap_minor] = 0;
694 mutex_unlock(&icap_sem);
710 return 0; /* success */ 695 return 0; /* success */
711} 696}
712 697
@@ -821,28 +806,29 @@ static struct of_platform_driver hwicap_of_driver = {
821}; 806};
822 807
823/* Registration helpers to keep the number of #ifdefs to a minimum */ 808/* Registration helpers to keep the number of #ifdefs to a minimum */
824static inline int __devinit hwicap_of_register(void) 809static inline int __init hwicap_of_register(void)
825{ 810{
826 pr_debug("hwicap: calling of_register_platform_driver()\n"); 811 pr_debug("hwicap: calling of_register_platform_driver()\n");
827 return of_register_platform_driver(&hwicap_of_driver); 812 return of_register_platform_driver(&hwicap_of_driver);
828} 813}
829 814
830static inline void __devexit hwicap_of_unregister(void) 815static inline void __exit hwicap_of_unregister(void)
831{ 816{
832 of_unregister_platform_driver(&hwicap_of_driver); 817 of_unregister_platform_driver(&hwicap_of_driver);
833} 818}
834#else /* CONFIG_OF */ 819#else /* CONFIG_OF */
835/* CONFIG_OF not enabled; do nothing helpers */ 820/* CONFIG_OF not enabled; do nothing helpers */
836static inline int __devinit hwicap_of_register(void) { return 0; } 821static inline int __init hwicap_of_register(void) { return 0; }
837static inline void __devexit hwicap_of_unregister(void) { } 822static inline void __exit hwicap_of_unregister(void) { }
838#endif /* CONFIG_OF */ 823#endif /* CONFIG_OF */
839 824
840static int __devinit hwicap_module_init(void) 825static int __init hwicap_module_init(void)
841{ 826{
842 dev_t devt; 827 dev_t devt;
843 int retval; 828 int retval;
844 829
845 icap_class = class_create(THIS_MODULE, "xilinx_config"); 830 icap_class = class_create(THIS_MODULE, "xilinx_config");
831 mutex_init(&icap_sem);
846 832
847 if (xhwicap_major) { 833 if (xhwicap_major) {
848 devt = MKDEV(xhwicap_major, xhwicap_minor); 834 devt = MKDEV(xhwicap_major, xhwicap_minor);
@@ -883,7 +869,7 @@ static int __devinit hwicap_module_init(void)
883 return retval; 869 return retval;
884} 870}
885 871
886static void __devexit hwicap_module_cleanup(void) 872static void __exit hwicap_module_cleanup(void)
887{ 873{
888 dev_t devt = MKDEV(xhwicap_major, xhwicap_minor); 874 dev_t devt = MKDEV(xhwicap_major, xhwicap_minor);
889 875
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.h b/drivers/char/xilinx_hwicap/xilinx_hwicap.h
index ae771cac1629..405fee7e189b 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.h
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.h
@@ -48,9 +48,9 @@ struct hwicap_drvdata {
48 u8 write_buffer[4]; 48 u8 write_buffer[4];
49 u32 read_buffer_in_use; /* Always in [0,3] */ 49 u32 read_buffer_in_use; /* Always in [0,3] */
50 u8 read_buffer[4]; 50 u8 read_buffer[4];
51 u32 mem_start; /* phys. address of the control registers */ 51 resource_size_t mem_start;/* phys. address of the control registers */
52 u32 mem_end; /* phys. address of the control registers */ 52 resource_size_t mem_end; /* phys. address of the control registers */
53 u32 mem_size; 53 resource_size_t mem_size;
54 void __iomem *base_address;/* virt. address of the control registers */ 54 void __iomem *base_address;/* virt. address of the control registers */
55 55
56 struct device *dev; 56 struct device *dev;
@@ -61,7 +61,7 @@ struct hwicap_drvdata {
61 const struct config_registers *config_regs; 61 const struct config_registers *config_regs;
62 void *private_data; 62 void *private_data;
63 bool is_open; 63 bool is_open;
64 struct semaphore sem; 64 struct mutex sem;
65}; 65};
66 66
67struct hwicap_driver_config { 67struct hwicap_driver_config {
@@ -164,29 +164,29 @@ struct config_registers {
164#define XHI_DISABLED_AUTO_CRC 0x0000DEFCUL 164#define XHI_DISABLED_AUTO_CRC 0x0000DEFCUL
165 165
166/** 166/**
167 * hwicap_type_1_read: Generates a Type 1 read packet header. 167 * hwicap_type_1_read - Generates a Type 1 read packet header.
168 * @parameter: Register is the address of the register to be read back. 168 * @reg: is the address of the register to be read back.
169 * 169 *
170 * Generates a Type 1 read packet header, which is used to indirectly 170 * Generates a Type 1 read packet header, which is used to indirectly
171 * read registers in the configuration logic. This packet must then 171 * read registers in the configuration logic. This packet must then
172 * be sent through the icap device, and a return packet received with 172 * be sent through the icap device, and a return packet received with
173 * the information. 173 * the information.
174 **/ 174 **/
175static inline u32 hwicap_type_1_read(u32 Register) 175static inline u32 hwicap_type_1_read(u32 reg)
176{ 176{
177 return (XHI_TYPE_1 << XHI_TYPE_SHIFT) | 177 return (XHI_TYPE_1 << XHI_TYPE_SHIFT) |
178 (Register << XHI_REGISTER_SHIFT) | 178 (reg << XHI_REGISTER_SHIFT) |
179 (XHI_OP_READ << XHI_OP_SHIFT); 179 (XHI_OP_READ << XHI_OP_SHIFT);
180} 180}
181 181
182/** 182/**
183 * hwicap_type_1_write: Generates a Type 1 write packet header 183 * hwicap_type_1_write - Generates a Type 1 write packet header
184 * @parameter: Register is the address of the register to be read back. 184 * @reg: is the address of the register to be read back.
185 **/ 185 **/
186static inline u32 hwicap_type_1_write(u32 Register) 186static inline u32 hwicap_type_1_write(u32 reg)
187{ 187{
188 return (XHI_TYPE_1 << XHI_TYPE_SHIFT) | 188 return (XHI_TYPE_1 << XHI_TYPE_SHIFT) |
189 (Register << XHI_REGISTER_SHIFT) | 189 (reg << XHI_REGISTER_SHIFT) |
190 (XHI_OP_WRITE << XHI_OP_SHIFT); 190 (XHI_OP_WRITE << XHI_OP_SHIFT);
191} 191}
192 192
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 0c303c84b37b..6b6df8679585 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -632,8 +632,7 @@ mpt_deregister(u8 cb_idx)
632 632
633/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 633/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
634/** 634/**
635 * mpt_event_register - Register protocol-specific event callback 635 * mpt_event_register - Register protocol-specific event callback handler.
636 * handler.
637 * @cb_idx: previously registered (via mpt_register) callback handle 636 * @cb_idx: previously registered (via mpt_register) callback handle
638 * @ev_cbfunc: callback function 637 * @ev_cbfunc: callback function
639 * 638 *
@@ -654,8 +653,7 @@ mpt_event_register(u8 cb_idx, MPT_EVHANDLER ev_cbfunc)
654 653
655/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 654/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
656/** 655/**
657 * mpt_event_deregister - Deregister protocol-specific event callback 656 * mpt_event_deregister - Deregister protocol-specific event callback handler
658 * handler.
659 * @cb_idx: previously registered callback handle 657 * @cb_idx: previously registered callback handle
660 * 658 *
661 * Each protocol-specific driver should call this routine 659 * Each protocol-specific driver should call this routine
@@ -765,11 +763,13 @@ mpt_device_driver_deregister(u8 cb_idx)
765 763
766/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 764/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
767/** 765/**
768 * mpt_get_msg_frame - Obtain a MPT request frame from the pool (of 1024) 766 * mpt_get_msg_frame - Obtain an MPT request frame from the pool
769 * allocated per MPT adapter.
770 * @cb_idx: Handle of registered MPT protocol driver 767 * @cb_idx: Handle of registered MPT protocol driver
771 * @ioc: Pointer to MPT adapter structure 768 * @ioc: Pointer to MPT adapter structure
772 * 769 *
770 * Obtain an MPT request frame from the pool (of 1024) that are
771 * allocated per MPT adapter.
772 *
773 * Returns pointer to a MPT request frame or %NULL if none are available 773 * Returns pointer to a MPT request frame or %NULL if none are available
774 * or IOC is not active. 774 * or IOC is not active.
775 */ 775 */
@@ -834,13 +834,12 @@ mpt_get_msg_frame(u8 cb_idx, MPT_ADAPTER *ioc)
834 834
835/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 835/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
836/** 836/**
837 * mpt_put_msg_frame - Send a protocol specific MPT request frame 837 * mpt_put_msg_frame - Send a protocol-specific MPT request frame to an IOC
838 * to a IOC.
839 * @cb_idx: Handle of registered MPT protocol driver 838 * @cb_idx: Handle of registered MPT protocol driver
840 * @ioc: Pointer to MPT adapter structure 839 * @ioc: Pointer to MPT adapter structure
841 * @mf: Pointer to MPT request frame 840 * @mf: Pointer to MPT request frame
842 * 841 *
843 * This routine posts a MPT request frame to the request post FIFO of a 842 * This routine posts an MPT request frame to the request post FIFO of a
844 * specific MPT adapter. 843 * specific MPT adapter.
845 */ 844 */
846void 845void
@@ -868,13 +867,15 @@ mpt_put_msg_frame(u8 cb_idx, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf)
868} 867}
869 868
870/** 869/**
871 * mpt_put_msg_frame_hi_pri - Send a protocol specific MPT request frame 870 * mpt_put_msg_frame_hi_pri - Send a hi-pri protocol-specific MPT request frame
872 * to a IOC using hi priority request queue.
873 * @cb_idx: Handle of registered MPT protocol driver 871 * @cb_idx: Handle of registered MPT protocol driver
874 * @ioc: Pointer to MPT adapter structure 872 * @ioc: Pointer to MPT adapter structure
875 * @mf: Pointer to MPT request frame 873 * @mf: Pointer to MPT request frame
876 * 874 *
877 * This routine posts a MPT request frame to the request post FIFO of a 875 * Send a protocol-specific MPT request frame to an IOC using
876 * hi-priority request queue.
877 *
878 * This routine posts an MPT request frame to the request post FIFO of a
878 * specific MPT adapter. 879 * specific MPT adapter.
879 **/ 880 **/
880void 881void
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index af1de0ccee2f..0c252f60c4c1 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -1533,7 +1533,7 @@ mptscsih_freeChainBuffers(MPT_ADAPTER *ioc, int req_idx)
1533 * 1533 *
1534 * Remark: Currently invoked from a non-interrupt thread (_bh). 1534 * Remark: Currently invoked from a non-interrupt thread (_bh).
1535 * 1535 *
1536 * Remark: With old EH code, at most 1 SCSI TaskMgmt function per IOC 1536 * Note: With old EH code, at most 1 SCSI TaskMgmt function per IOC
1537 * will be active. 1537 * will be active.
1538 * 1538 *
1539 * Returns 0 for SUCCESS, or %FAILED. 1539 * Returns 0 for SUCCESS, or %FAILED.
@@ -2537,14 +2537,12 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR
2537 2537
2538/** 2538/**
2539 * mptscsih_get_scsi_lookup 2539 * mptscsih_get_scsi_lookup
2540 *
2541 * retrieves scmd entry from ScsiLookup[] array list
2542 *
2543 * @ioc: Pointer to MPT_ADAPTER structure 2540 * @ioc: Pointer to MPT_ADAPTER structure
2544 * @i: index into the array 2541 * @i: index into the array
2545 * 2542 *
2546 * Returns the scsi_cmd pointer 2543 * retrieves scmd entry from ScsiLookup[] array list
2547 * 2544 *
2545 * Returns the scsi_cmd pointer
2548 **/ 2546 **/
2549static struct scsi_cmnd * 2547static struct scsi_cmnd *
2550mptscsih_get_scsi_lookup(MPT_ADAPTER *ioc, int i) 2548mptscsih_get_scsi_lookup(MPT_ADAPTER *ioc, int i)
@@ -2561,14 +2559,12 @@ mptscsih_get_scsi_lookup(MPT_ADAPTER *ioc, int i)
2561 2559
2562/** 2560/**
2563 * mptscsih_getclear_scsi_lookup 2561 * mptscsih_getclear_scsi_lookup
2564 *
2565 * retrieves and clears scmd entry from ScsiLookup[] array list
2566 *
2567 * @ioc: Pointer to MPT_ADAPTER structure 2562 * @ioc: Pointer to MPT_ADAPTER structure
2568 * @i: index into the array 2563 * @i: index into the array
2569 * 2564 *
2570 * Returns the scsi_cmd pointer 2565 * retrieves and clears scmd entry from ScsiLookup[] array list
2571 * 2566 *
2567 * Returns the scsi_cmd pointer
2572 **/ 2568 **/
2573static struct scsi_cmnd * 2569static struct scsi_cmnd *
2574mptscsih_getclear_scsi_lookup(MPT_ADAPTER *ioc, int i) 2570mptscsih_getclear_scsi_lookup(MPT_ADAPTER *ioc, int i)
diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index 0fbf1bbbaee9..d7a3ea88eddb 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -1253,7 +1253,7 @@ static void __inline__ fec_request_intrs(struct net_device *dev)
1253 1253
1254 /* Setup interrupt handlers. */ 1254 /* Setup interrupt handlers. */
1255 for (idp = id; idp->name; idp++) { 1255 for (idp = id; idp->name; idp++) {
1256 if (request_irq(idp->irq, idp->handler, 0, idp->name, dev) != 0) 1256 if (request_irq(idp->irq, idp->handler, IRQF_DISABLED, idp->name, dev) != 0)
1257 printk("FEC: Could not allocate %s IRQ(%d)!\n", idp->name, idp->irq); 1257 printk("FEC: Could not allocate %s IRQ(%d)!\n", idp->name, idp->irq);
1258 } 1258 }
1259 1259
@@ -1382,7 +1382,7 @@ static void __inline__ fec_request_intrs(struct net_device *dev)
1382 1382
1383 /* Setup interrupt handlers. */ 1383 /* Setup interrupt handlers. */
1384 for (idp = id; idp->name; idp++) { 1384 for (idp = id; idp->name; idp++) {
1385 if (request_irq(b+idp->irq, fec_enet_interrupt, 0, idp->name, dev) != 0) 1385 if (request_irq(b+idp->irq, fec_enet_interrupt, IRQF_DISABLED, idp->name, dev) != 0)
1386 printk("FEC: Could not allocate %s IRQ(%d)!\n", idp->name, b+idp->irq); 1386 printk("FEC: Could not allocate %s IRQ(%d)!\n", idp->name, b+idp->irq);
1387 } 1387 }
1388 1388
@@ -1553,7 +1553,7 @@ static void __inline__ fec_request_intrs(struct net_device *dev)
1553 1553
1554 /* Setup interrupt handlers. */ 1554 /* Setup interrupt handlers. */
1555 for (idp = id; idp->name; idp++) { 1555 for (idp = id; idp->name; idp++) {
1556 if (request_irq(b+idp->irq,fec_enet_interrupt,0,idp->name,dev)!=0) 1556 if (request_irq(b+idp->irq, fec_enet_interrupt, IRQF_DISABLED, idp->name,dev) != 0)
1557 printk("FEC: Could not allocate %s IRQ(%d)!\n", idp->name, b+idp->irq); 1557 printk("FEC: Could not allocate %s IRQ(%d)!\n", idp->name, b+idp->irq);
1558 } 1558 }
1559 1559
@@ -1680,7 +1680,7 @@ static void __inline__ fec_request_intrs(struct net_device *dev)
1680 1680
1681 /* Setup interrupt handlers. */ 1681 /* Setup interrupt handlers. */
1682 for (idp = id; idp->name; idp++) { 1682 for (idp = id; idp->name; idp++) {
1683 if (request_irq(b+idp->irq,fec_enet_interrupt,0,idp->name,dev)!=0) 1683 if (request_irq(b+idp->irq, fec_enet_interrupt, IRQF_DISABLED, idp->name,dev) != 0)
1684 printk("FEC: Could not allocate %s IRQ(%d)!\n", 1684 printk("FEC: Could not allocate %s IRQ(%d)!\n",
1685 idp->name, b+idp->irq); 1685 idp->name, b+idp->irq);
1686 } 1686 }
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
index a98b2470b9ea..bd5c0e031398 100644
--- a/drivers/pci/rom.c
+++ b/drivers/pci/rom.c
@@ -242,8 +242,7 @@ void pci_remove_rom(struct pci_dev *pdev)
242#endif /* 0 */ 242#endif /* 0 */
243 243
244/** 244/**
245 * pci_cleanup_rom - internal routine for freeing the ROM copy created 245 * pci_cleanup_rom - free the ROM copy created by pci_map_rom_copy
246 * by pci_map_rom_copy called from remove.c
247 * @pdev: pointer to pci device struct 246 * @pdev: pointer to pci device struct
248 * 247 *
249 * Free the copied ROM if we allocated one. 248 * Free the copied ROM if we allocated one.
diff --git a/drivers/rapidio/rio-driver.c b/drivers/rapidio/rio-driver.c
index 5480119ff9d3..3ce9f3defc12 100644
--- a/drivers/rapidio/rio-driver.c
+++ b/drivers/rapidio/rio-driver.c
@@ -78,8 +78,7 @@ void rio_dev_put(struct rio_dev *rdev)
78} 78}
79 79
80/** 80/**
81 * rio_device_probe - Tell if a RIO device structure has a matching RIO 81 * rio_device_probe - Tell if a RIO device structure has a matching RIO device id structure
82 * device id structure
83 * @id: the RIO device id structure to match against 82 * @id: the RIO device id structure to match against
84 * @dev: the RIO device structure to match against 83 * @dev: the RIO device structure to match against
85 * 84 *
@@ -137,7 +136,7 @@ static int rio_device_remove(struct device *dev)
137 * rio_register_driver - register a new RIO driver 136 * rio_register_driver - register a new RIO driver
138 * @rdrv: the RIO driver structure to register 137 * @rdrv: the RIO driver structure to register
139 * 138 *
140 * Adds a &struct rio_driver to the list of registered drivers 139 * Adds a &struct rio_driver to the list of registered drivers.
141 * Returns a negative value on error, otherwise 0. If no error 140 * Returns a negative value on error, otherwise 0. If no error
142 * occurred, the driver remains registered even if no device 141 * occurred, the driver remains registered even if no device
143 * was claimed during registration. 142 * was claimed during registration.
@@ -167,8 +166,7 @@ void rio_unregister_driver(struct rio_driver *rdrv)
167} 166}
168 167
169/** 168/**
170 * rio_match_bus - Tell if a RIO device structure has a matching RIO 169 * rio_match_bus - Tell if a RIO device structure has a matching RIO driver device id structure
171 * driver device id structure
172 * @dev: the standard device structure to match against 170 * @dev: the standard device structure to match against
173 * @drv: the standard driver structure containing the ids to match against 171 * @drv: the standard driver structure containing the ids to match against
174 * 172 *
diff --git a/drivers/s390/char/defkeymap.c b/drivers/s390/char/defkeymap.c
index 389346cda6c8..07c7f31081bc 100644
--- a/drivers/s390/char/defkeymap.c
+++ b/drivers/s390/char/defkeymap.c
@@ -151,8 +151,8 @@ char *func_table[MAX_NR_FUNC] = {
151}; 151};
152 152
153struct kbdiacruc accent_table[MAX_DIACR] = { 153struct kbdiacruc accent_table[MAX_DIACR] = {
154 {'^', 'c', '\003'}, {'^', 'd', '\004'}, 154 {'^', 'c', 0003}, {'^', 'd', 0004},
155 {'^', 'z', '\032'}, {'^', '\012', '\000'}, 155 {'^', 'z', 0032}, {'^', 0012, 0000},
156}; 156};
157 157
158unsigned int accent_table_size = 4; 158unsigned int accent_table_size = 4;
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 1dc165ad17fb..e67c14e31bab 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1577,8 +1577,7 @@ static void __scsi_scan_target(struct device *parent, unsigned int channel,
1577} 1577}
1578 1578
1579/** 1579/**
1580 * scsi_scan_target - scan a target id, possibly including all LUNs on the 1580 * scsi_scan_target - scan a target id, possibly including all LUNs on the target.
1581 * target.
1582 * @parent: host to scan 1581 * @parent: host to scan
1583 * @channel: channel to scan 1582 * @channel: channel to scan
1584 * @id: target id to scan 1583 * @id: target id to scan
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 4e984060c984..f6f19908f5f0 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -99,8 +99,7 @@ struct usb_interface *usb_ifnum_to_if(const struct usb_device *dev,
99EXPORT_SYMBOL_GPL(usb_ifnum_to_if); 99EXPORT_SYMBOL_GPL(usb_ifnum_to_if);
100 100
101/** 101/**
102 * usb_altnum_to_altsetting - get the altsetting structure with a given 102 * usb_altnum_to_altsetting - get the altsetting structure with a given alternate setting number.
103 * alternate setting number.
104 * @intf: the interface containing the altsetting in question 103 * @intf: the interface containing the altsetting in question
105 * @altnum: the desired alternate setting number 104 * @altnum: the desired alternate setting number
106 * 105 *
@@ -442,8 +441,7 @@ EXPORT_SYMBOL_GPL(usb_put_intf);
442 */ 441 */
443 442
444/** 443/**
445 * usb_lock_device_for_reset - cautiously acquire the lock for a 444 * usb_lock_device_for_reset - cautiously acquire the lock for a usb device structure
446 * usb device structure
447 * @udev: device that's being locked 445 * @udev: device that's being locked
448 * @iface: interface bound to the driver making the request (optional) 446 * @iface: interface bound to the driver making the request (optional)
449 * 447 *
diff --git a/fs/buffer.c b/fs/buffer.c
index 3ebccf4aa7e3..897cd7477b34 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -627,8 +627,7 @@ repeat:
627} 627}
628 628
629/** 629/**
630 * sync_mapping_buffers - write out and wait upon a mapping's "associated" 630 * sync_mapping_buffers - write out & wait upon a mapping's "associated" buffers
631 * buffers
632 * @mapping: the mapping which wants those buffers written 631 * @mapping: the mapping which wants those buffers written
633 * 632 *
634 * Starts I/O against the buffers at mapping->private_list, and waits upon 633 * Starts I/O against the buffers at mapping->private_list, and waits upon
diff --git a/fs/cifs/CHANGES b/fs/cifs/CHANGES
index edd248367b36..dbd91461853c 100644
--- a/fs/cifs/CHANGES
+++ b/fs/cifs/CHANGES
@@ -6,7 +6,9 @@ and sync so that events like out of disk space get reported properly on
6cached files. Fix setxattr failure to certain Samba versions. Fix mount 6cached files. Fix setxattr failure to certain Samba versions. Fix mount
7of second share to disconnected server session (autoreconnect on this). 7of second share to disconnected server session (autoreconnect on this).
8Add ability to modify cifs acls for handling chmod (when mounted with 8Add ability to modify cifs acls for handling chmod (when mounted with
9cifsacl flag). 9cifsacl flag). Fix prefixpath path separator so we can handle mounts
10with prefixpaths longer than one directory (one path component) when
11mounted to Windows servers.
10 12
11Version 1.51 13Version 1.51
12------------ 14------------
diff --git a/fs/cifs/README b/fs/cifs/README
index c623e2f9c5db..50306229b0f9 100644
--- a/fs/cifs/README
+++ b/fs/cifs/README
@@ -461,7 +461,7 @@ A partial list of the supported mount options follows:
461 cifsacl Report mode bits (e.g. on stat) based on the Windows ACL for 461 cifsacl Report mode bits (e.g. on stat) based on the Windows ACL for
462 the file. (EXPERIMENTAL) 462 the file. (EXPERIMENTAL)
463 servern Specify the server 's netbios name (RFC1001 name) to use 463 servern Specify the server 's netbios name (RFC1001 name) to use
464 when attempting to setup a session to the server. This is 464 when attempting to setup a session to the server.
465 This is needed for mounting to some older servers (such 465 This is needed for mounting to some older servers (such
466 as OS/2 or Windows 98 and Windows ME) since they do not 466 as OS/2 or Windows 98 and Windows ME) since they do not
467 support a default server name. A server name can be up 467 support a default server name. A server name can be up
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
index 73c4c419663c..0228ed06069e 100644
--- a/fs/cifs/cifs_debug.c
+++ b/fs/cifs/cifs_debug.c
@@ -98,8 +98,7 @@ void cifs_dump_mids(struct TCP_Server_Info *server)
98 if (mid_entry->resp_buf) { 98 if (mid_entry->resp_buf) {
99 cifs_dump_detail(mid_entry->resp_buf); 99 cifs_dump_detail(mid_entry->resp_buf);
100 cifs_dump_mem("existing buf: ", 100 cifs_dump_mem("existing buf: ",
101 mid_entry->resp_buf, 101 mid_entry->resp_buf, 62);
102 62 /* fixme */);
103 } 102 }
104 } 103 }
105 } 104 }
@@ -439,7 +438,7 @@ cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
439 438
440 return length; 439 return length;
441} 440}
442#endif 441#endif /* STATS */
443 442
444static struct proc_dir_entry *proc_fs_cifs; 443static struct proc_dir_entry *proc_fs_cifs;
445read_proc_t cifs_txanchor_read; 444read_proc_t cifs_txanchor_read;
@@ -482,7 +481,7 @@ cifs_proc_init(void)
482 cifs_stats_read, NULL); 481 cifs_stats_read, NULL);
483 if (pde) 482 if (pde)
484 pde->write_proc = cifs_stats_write; 483 pde->write_proc = cifs_stats_write;
485#endif 484#endif /* STATS */
486 pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs, 485 pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs,
487 cifsFYI_read, NULL); 486 cifsFYI_read, NULL);
488 if (pde) 487 if (pde)
@@ -918,4 +917,12 @@ security_flags_write(struct file *file, const char __user *buffer,
918 /* BB should we turn on MAY flags for other MUST options? */ 917 /* BB should we turn on MAY flags for other MUST options? */
919 return count; 918 return count;
920} 919}
921#endif 920#else
921inline void cifs_proc_init(void)
922{
923}
924
925inline void cifs_proc_clean(void)
926{
927}
928#endif /* PROC_FS */
diff --git a/fs/cifs/cifs_debug.h b/fs/cifs/cifs_debug.h
index c26cd0d2c6d5..5eb3b83bbfa7 100644
--- a/fs/cifs/cifs_debug.h
+++ b/fs/cifs/cifs_debug.h
@@ -25,8 +25,11 @@
25 25
26void cifs_dump_mem(char *label, void *data, int length); 26void cifs_dump_mem(char *label, void *data, int length);
27#ifdef CONFIG_CIFS_DEBUG2 27#ifdef CONFIG_CIFS_DEBUG2
28#define DBG2 2
28void cifs_dump_detail(struct smb_hdr *); 29void cifs_dump_detail(struct smb_hdr *);
29void cifs_dump_mids(struct TCP_Server_Info *); 30void cifs_dump_mids(struct TCP_Server_Info *);
31#else
32#define DBG2 0
30#endif 33#endif
31extern int traceSMB; /* flag which enables the function below */ 34extern int traceSMB; /* flag which enables the function below */
32void dump_smb(struct smb_hdr *, int); 35void dump_smb(struct smb_hdr *, int);
@@ -64,10 +67,10 @@ extern int cifsERROR;
64 * --------- 67 * ---------
65 */ 68 */
66#else /* _CIFS_DEBUG */ 69#else /* _CIFS_DEBUG */
67#define cERROR(button,prspec) 70#define cERROR(button, prspec)
68#define cEVENT(format,arg...) 71#define cEVENT(format, arg...)
69#define cFYI(button, prspec) 72#define cFYI(button, prspec)
70#define cifserror(format,arg...) 73#define cifserror(format, arg...)
71#endif /* _CIFS_DEBUG */ 74#endif /* _CIFS_DEBUG */
72 75
73#endif /* _H_CIFS_DEBUG */ 76#endif /* _H_CIFS_DEBUG */
diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c
index 6ad447529961..7f8838253410 100644
--- a/fs/cifs/cifs_dfs_ref.c
+++ b/fs/cifs/cifs_dfs_ref.c
@@ -286,7 +286,7 @@ static void dump_referral(const struct dfs_info3_param *ref)
286 cFYI(1, ("DFS: node path: %s", ref->node_name)); 286 cFYI(1, ("DFS: node path: %s", ref->node_name));
287 cFYI(1, ("DFS: fl: %hd, srv_type: %hd", ref->flags, ref->server_type)); 287 cFYI(1, ("DFS: fl: %hd, srv_type: %hd", ref->flags, ref->server_type));
288 cFYI(1, ("DFS: ref_flags: %hd, path_consumed: %hd", ref->ref_flag, 288 cFYI(1, ("DFS: ref_flags: %hd, path_consumed: %hd", ref->ref_flag,
289 ref->PathConsumed)); 289 ref->path_consumed));
290} 290}
291 291
292 292
diff --git a/fs/cifs/cifs_spnego.c b/fs/cifs/cifs_spnego.c
index d543accc10dd..6653e29637a7 100644
--- a/fs/cifs/cifs_spnego.c
+++ b/fs/cifs/cifs_spnego.c
@@ -125,7 +125,7 @@ cifs_get_spnego_key(struct cifsSesInfo *sesInfo)
125#ifdef CONFIG_CIFS_DEBUG2 125#ifdef CONFIG_CIFS_DEBUG2
126 if (cifsFYI && !IS_ERR(spnego_key)) { 126 if (cifsFYI && !IS_ERR(spnego_key)) {
127 struct cifs_spnego_msg *msg = spnego_key->payload.data; 127 struct cifs_spnego_msg *msg = spnego_key->payload.data;
128 cifs_dump_mem("SPNEGO reply blob:", msg->data, min(1024, 128 cifs_dump_mem("SPNEGO reply blob:", msg->data, min(1024U,
129 msg->secblob_len + msg->sesskey_len)); 129 msg->secblob_len + msg->sesskey_len));
130 } 130 }
131#endif /* CONFIG_CIFS_DEBUG2 */ 131#endif /* CONFIG_CIFS_DEBUG2 */
diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c
index b5903b89250d..7d75272a6b3f 100644
--- a/fs/cifs/cifs_unicode.c
+++ b/fs/cifs/cifs_unicode.c
@@ -32,7 +32,7 @@
32 * 32 *
33 */ 33 */
34int 34int
35cifs_strfromUCS_le(char *to, const __le16 * from, 35cifs_strfromUCS_le(char *to, const __le16 *from,
36 int len, const struct nls_table *codepage) 36 int len, const struct nls_table *codepage)
37{ 37{
38 int i; 38 int i;
@@ -61,7 +61,7 @@ cifs_strfromUCS_le(char *to, const __le16 * from,
61 * 61 *
62 */ 62 */
63int 63int
64cifs_strtoUCS(__le16 * to, const char *from, int len, 64cifs_strtoUCS(__le16 *to, const char *from, int len,
65 const struct nls_table *codepage) 65 const struct nls_table *codepage)
66{ 66{
67 int charlen; 67 int charlen;
diff --git a/fs/cifs/cifs_unicode.h b/fs/cifs/cifs_unicode.h
index 614c11fcdcb6..14eb9a2395d3 100644
--- a/fs/cifs/cifs_unicode.h
+++ b/fs/cifs/cifs_unicode.h
@@ -254,7 +254,8 @@ UniStrstr(const wchar_t *ucs1, const wchar_t *ucs2)
254 const wchar_t *anchor2 = ucs2; 254 const wchar_t *anchor2 = ucs2;
255 255
256 while (*ucs1) { 256 while (*ucs1) {
257 if (*ucs1 == *ucs2) { /* Partial match found */ 257 if (*ucs1 == *ucs2) {
258 /* Partial match found */
258 ucs1++; 259 ucs1++;
259 ucs2++; 260 ucs2++;
260 } else { 261 } else {
@@ -279,7 +280,8 @@ UniToupper(register wchar_t uc)
279{ 280{
280 register const struct UniCaseRange *rp; 281 register const struct UniCaseRange *rp;
281 282
282 if (uc < sizeof (CifsUniUpperTable)) { /* Latin characters */ 283 if (uc < sizeof(CifsUniUpperTable)) {
284 /* Latin characters */
283 return uc + CifsUniUpperTable[uc]; /* Use base tables */ 285 return uc + CifsUniUpperTable[uc]; /* Use base tables */
284 } else { 286 } else {
285 rp = CifsUniUpperRange; /* Use range tables */ 287 rp = CifsUniUpperRange; /* Use range tables */
@@ -320,7 +322,8 @@ UniTolower(wchar_t uc)
320{ 322{
321 register struct UniCaseRange *rp; 323 register struct UniCaseRange *rp;
322 324
323 if (uc < sizeof (UniLowerTable)) { /* Latin characters */ 325 if (uc < sizeof(UniLowerTable)) {
326 /* Latin characters */
324 return uc + UniLowerTable[uc]; /* Use base tables */ 327 return uc + UniLowerTable[uc]; /* Use base tables */
325 } else { 328 } else {
326 rp = UniLowerRange; /* Use range tables */ 329 rp = UniLowerRange; /* Use range tables */
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
index a7035bd18e4e..f93932c21772 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -46,8 +46,7 @@ static struct cifs_wksid wksidarr[NUM_WK_SIDS] = {
46static const struct cifs_sid sid_everyone = { 46static const struct cifs_sid sid_everyone = {
47 1, 1, {0, 0, 0, 0, 0, 1}, {0} }; 47 1, 1, {0, 0, 0, 0, 0, 1}, {0} };
48/* group users */ 48/* group users */
49static const struct cifs_sid sid_user = 49static const struct cifs_sid sid_user = {1, 2 , {0, 0, 0, 0, 0, 5}, {} };
50 {1, 2 , {0, 0, 0, 0, 0, 5}, {} };
51 50
52 51
53int match_sid(struct cifs_sid *ctsid) 52int match_sid(struct cifs_sid *ctsid)
@@ -195,9 +194,9 @@ static void access_flags_to_mode(__le32 ace_flags, int type, umode_t *pmode,
195 /* For deny ACEs we change the mask so that subsequent allow access 194 /* For deny ACEs we change the mask so that subsequent allow access
196 control entries do not turn on the bits we are denying */ 195 control entries do not turn on the bits we are denying */
197 if (type == ACCESS_DENIED) { 196 if (type == ACCESS_DENIED) {
198 if (flags & GENERIC_ALL) { 197 if (flags & GENERIC_ALL)
199 *pbits_to_set &= ~S_IRWXUGO; 198 *pbits_to_set &= ~S_IRWXUGO;
200 } 199
201 if ((flags & GENERIC_WRITE) || 200 if ((flags & GENERIC_WRITE) ||
202 ((flags & FILE_WRITE_RIGHTS) == FILE_WRITE_RIGHTS)) 201 ((flags & FILE_WRITE_RIGHTS) == FILE_WRITE_RIGHTS))
203 *pbits_to_set &= ~S_IWUGO; 202 *pbits_to_set &= ~S_IWUGO;
@@ -216,9 +215,7 @@ static void access_flags_to_mode(__le32 ace_flags, int type, umode_t *pmode,
216 215
217 if (flags & GENERIC_ALL) { 216 if (flags & GENERIC_ALL) {
218 *pmode |= (S_IRWXUGO & (*pbits_to_set)); 217 *pmode |= (S_IRWXUGO & (*pbits_to_set));
219#ifdef CONFIG_CIFS_DEBUG2 218 cFYI(DBG2, ("all perms"));
220 cFYI(1, ("all perms"));
221#endif
222 return; 219 return;
223 } 220 }
224 if ((flags & GENERIC_WRITE) || 221 if ((flags & GENERIC_WRITE) ||
@@ -231,9 +228,7 @@ static void access_flags_to_mode(__le32 ace_flags, int type, umode_t *pmode,
231 ((flags & FILE_EXEC_RIGHTS) == FILE_EXEC_RIGHTS)) 228 ((flags & FILE_EXEC_RIGHTS) == FILE_EXEC_RIGHTS))
232 *pmode |= (S_IXUGO & (*pbits_to_set)); 229 *pmode |= (S_IXUGO & (*pbits_to_set));
233 230
234#ifdef CONFIG_CIFS_DEBUG2 231 cFYI(DBG2, ("access flags 0x%x mode now 0x%x", flags, *pmode));
235 cFYI(1, ("access flags 0x%x mode now 0x%x", flags, *pmode));
236#endif
237 return; 232 return;
238} 233}
239 234
@@ -262,9 +257,7 @@ static void mode_to_access_flags(umode_t mode, umode_t bits_to_use,
262 if (mode & S_IXUGO) 257 if (mode & S_IXUGO)
263 *pace_flags |= SET_FILE_EXEC_RIGHTS; 258 *pace_flags |= SET_FILE_EXEC_RIGHTS;
264 259
265#ifdef CONFIG_CIFS_DEBUG2 260 cFYI(DBG2, ("mode: 0x%x, access flags now 0x%x", mode, *pace_flags));
266 cFYI(1, ("mode: 0x%x, access flags now 0x%x", mode, *pace_flags));
267#endif
268 return; 261 return;
269} 262}
270 263
@@ -358,11 +351,9 @@ static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl,
358 return; 351 return;
359 } 352 }
360 353
361#ifdef CONFIG_CIFS_DEBUG2 354 cFYI(DBG2, ("DACL revision %d size %d num aces %d",
362 cFYI(1, ("DACL revision %d size %d num aces %d",
363 le16_to_cpu(pdacl->revision), le16_to_cpu(pdacl->size), 355 le16_to_cpu(pdacl->revision), le16_to_cpu(pdacl->size),
364 le32_to_cpu(pdacl->num_aces))); 356 le32_to_cpu(pdacl->num_aces)));
365#endif
366 357
367 /* reset rwx permissions for user/group/other. 358 /* reset rwx permissions for user/group/other.
368 Also, if num_aces is 0 i.e. DACL has no ACEs, 359 Also, if num_aces is 0 i.e. DACL has no ACEs,
@@ -381,10 +372,6 @@ static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl,
381 ppace = kmalloc(num_aces * sizeof(struct cifs_ace *), 372 ppace = kmalloc(num_aces * sizeof(struct cifs_ace *),
382 GFP_KERNEL); 373 GFP_KERNEL);
383 374
384/* cifscred->cecount = pdacl->num_aces;
385 cifscred->aces = kmalloc(num_aces *
386 sizeof(struct cifs_ace *), GFP_KERNEL);*/
387
388 for (i = 0; i < num_aces; ++i) { 375 for (i = 0; i < num_aces; ++i) {
389 ppace[i] = (struct cifs_ace *) (acl_base + acl_size); 376 ppace[i] = (struct cifs_ace *) (acl_base + acl_size);
390#ifdef CONFIG_CIFS_DEBUG2 377#ifdef CONFIG_CIFS_DEBUG2
@@ -437,7 +424,7 @@ static int set_chmod_dacl(struct cifs_acl *pndacl, struct cifs_sid *pownersid,
437 &sid_everyone, nmode, S_IRWXO); 424 &sid_everyone, nmode, S_IRWXO);
438 425
439 pndacl->size = cpu_to_le16(size + sizeof(struct cifs_acl)); 426 pndacl->size = cpu_to_le16(size + sizeof(struct cifs_acl));
440 pndacl->num_aces = 3; 427 pndacl->num_aces = cpu_to_le32(3);
441 428
442 return (0); 429 return (0);
443} 430}
@@ -495,13 +482,11 @@ static int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len,
495 le32_to_cpu(pntsd->gsidoffset)); 482 le32_to_cpu(pntsd->gsidoffset));
496 dacloffset = le32_to_cpu(pntsd->dacloffset); 483 dacloffset = le32_to_cpu(pntsd->dacloffset);
497 dacl_ptr = (struct cifs_acl *)((char *)pntsd + dacloffset); 484 dacl_ptr = (struct cifs_acl *)((char *)pntsd + dacloffset);
498#ifdef CONFIG_CIFS_DEBUG2 485 cFYI(DBG2, ("revision %d type 0x%x ooffset 0x%x goffset 0x%x "
499 cFYI(1, ("revision %d type 0x%x ooffset 0x%x goffset 0x%x "
500 "sacloffset 0x%x dacloffset 0x%x", 486 "sacloffset 0x%x dacloffset 0x%x",
501 pntsd->revision, pntsd->type, le32_to_cpu(pntsd->osidoffset), 487 pntsd->revision, pntsd->type, le32_to_cpu(pntsd->osidoffset),
502 le32_to_cpu(pntsd->gsidoffset), 488 le32_to_cpu(pntsd->gsidoffset),
503 le32_to_cpu(pntsd->sacloffset), dacloffset)); 489 le32_to_cpu(pntsd->sacloffset), dacloffset));
504#endif
505/* cifs_dump_mem("owner_sid: ", owner_sid_ptr, 64); */ 490/* cifs_dump_mem("owner_sid: ", owner_sid_ptr, 64); */
506 rc = parse_sid(owner_sid_ptr, end_of_acl); 491 rc = parse_sid(owner_sid_ptr, end_of_acl);
507 if (rc) 492 if (rc)
@@ -636,9 +621,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
636 struct super_block *sb; 621 struct super_block *sb;
637 struct cifs_sb_info *cifs_sb; 622 struct cifs_sb_info *cifs_sb;
638 623
639#ifdef CONFIG_CIFS_DEBUG2 624 cFYI(DBG2, ("set ACL for %s from mode 0x%x", path, inode->i_mode));
640 cFYI(1, ("set ACL for %s from mode 0x%x", path, inode->i_mode));
641#endif
642 625
643 if (!inode) 626 if (!inode)
644 return (rc); 627 return (rc);
@@ -669,9 +652,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
669 } 652 }
670 653
671 rc = CIFSSMBSetCIFSACL(xid, cifs_sb->tcon, fid, pnntsd, acllen); 654 rc = CIFSSMBSetCIFSACL(xid, cifs_sb->tcon, fid, pnntsd, acllen);
672#ifdef CONFIG_CIFS_DEBUG2 655 cFYI(DBG2, ("SetCIFSACL rc = %d", rc));
673 cFYI(1, ("SetCIFSACL rc = %d", rc));
674#endif
675 if (unlock_file == TRUE) 656 if (unlock_file == TRUE)
676 atomic_dec(&open_file->wrtPending); 657 atomic_dec(&open_file->wrtPending);
677 else 658 else
@@ -689,9 +670,7 @@ void acl_to_uid_mode(struct inode *inode, const char *path)
689 u32 acllen = 0; 670 u32 acllen = 0;
690 int rc = 0; 671 int rc = 0;
691 672
692#ifdef CONFIG_CIFS_DEBUG2 673 cFYI(DBG2, ("converting ACL to mode for %s", path));
693 cFYI(1, ("converting ACL to mode for %s", path));
694#endif
695 pntsd = get_cifs_acl(&acllen, inode, path); 674 pntsd = get_cifs_acl(&acllen, inode, path);
696 675
697 /* if we can retrieve the ACL, now parse Access Control Entries, ACEs */ 676 /* if we can retrieve the ACL, now parse Access Control Entries, ACEs */
@@ -712,9 +691,7 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode)
712 struct cifs_ntsd *pntsd = NULL; /* acl obtained from server */ 691 struct cifs_ntsd *pntsd = NULL; /* acl obtained from server */
713 struct cifs_ntsd *pnntsd = NULL; /* modified acl to be sent to server */ 692 struct cifs_ntsd *pnntsd = NULL; /* modified acl to be sent to server */
714 693
715#ifdef CONFIG_CIFS_DEBUG2 694 cFYI(DBG2, ("set ACL from mode for %s", path));
716 cFYI(1, ("set ACL from mode for %s", path));
717#endif
718 695
719 /* Get the security descriptor */ 696 /* Get the security descriptor */
720 pntsd = get_cifs_acl(&acllen, inode, path); 697 pntsd = get_cifs_acl(&acllen, inode, path);
@@ -736,16 +713,12 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode)
736 713
737 rc = build_sec_desc(pntsd, pnntsd, acllen, inode, nmode); 714 rc = build_sec_desc(pntsd, pnntsd, acllen, inode, nmode);
738 715
739#ifdef CONFIG_CIFS_DEBUG2 716 cFYI(DBG2, ("build_sec_desc rc: %d", rc));
740 cFYI(1, ("build_sec_desc rc: %d", rc));
741#endif
742 717
743 if (!rc) { 718 if (!rc) {
744 /* Set the security descriptor */ 719 /* Set the security descriptor */
745 rc = set_cifs_acl(pnntsd, acllen, inode, path); 720 rc = set_cifs_acl(pnntsd, acllen, inode, path);
746#ifdef CONFIG_CIFS_DEBUG2 721 cFYI(DBG2, ("set_cifs_acl rc: %d", rc));
747 cFYI(1, ("set_cifs_acl rc: %d", rc));
748#endif
749 } 722 }
750 723
751 kfree(pnntsd); 724 kfree(pnntsd);
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index fcc434227691..a04b17e5a9d0 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -204,9 +204,8 @@ cifs_put_super(struct super_block *sb)
204 return; 204 return;
205 } 205 }
206 rc = cifs_umount(sb, cifs_sb); 206 rc = cifs_umount(sb, cifs_sb);
207 if (rc) { 207 if (rc)
208 cERROR(1, ("cifs_umount failed with return code %d", rc)); 208 cERROR(1, ("cifs_umount failed with return code %d", rc));
209 }
210#ifdef CONFIG_CIFS_DFS_UPCALL 209#ifdef CONFIG_CIFS_DFS_UPCALL
211 if (cifs_sb->mountdata) { 210 if (cifs_sb->mountdata) {
212 kfree(cifs_sb->mountdata); 211 kfree(cifs_sb->mountdata);
@@ -461,7 +460,7 @@ int cifs_xstate_get(struct super_block *sb, struct fs_quota_stat *qstats)
461 460
462static struct quotactl_ops cifs_quotactl_ops = { 461static struct quotactl_ops cifs_quotactl_ops = {
463 .set_xquota = cifs_xquota_set, 462 .set_xquota = cifs_xquota_set,
464 .get_xquota = cifs_xquota_set, 463 .get_xquota = cifs_xquota_get,
465 .set_xstate = cifs_xstate_set, 464 .set_xstate = cifs_xstate_set,
466 .get_xstate = cifs_xstate_get, 465 .get_xstate = cifs_xstate_get,
467}; 466};
@@ -472,9 +471,7 @@ static void cifs_umount_begin(struct vfsmount *vfsmnt, int flags)
472 struct cifs_sb_info *cifs_sb; 471 struct cifs_sb_info *cifs_sb;
473 struct cifsTconInfo *tcon; 472 struct cifsTconInfo *tcon;
474 473
475#ifdef CONFIG_CIFS_DFS_UPCALL
476 dfs_shrink_umount_helper(vfsmnt); 474 dfs_shrink_umount_helper(vfsmnt);
477#endif /* CONFIG CIFS_DFS_UPCALL */
478 475
479 if (!(flags & MNT_FORCE)) 476 if (!(flags & MNT_FORCE))
480 return; 477 return;
@@ -992,9 +989,7 @@ static int __init
992init_cifs(void) 989init_cifs(void)
993{ 990{
994 int rc = 0; 991 int rc = 0;
995#ifdef CONFIG_PROC_FS
996 cifs_proc_init(); 992 cifs_proc_init();
997#endif
998/* INIT_LIST_HEAD(&GlobalServerList);*/ /* BB not implemented yet */ 993/* INIT_LIST_HEAD(&GlobalServerList);*/ /* BB not implemented yet */
999 INIT_LIST_HEAD(&GlobalSMBSessionList); 994 INIT_LIST_HEAD(&GlobalSMBSessionList);
1000 INIT_LIST_HEAD(&GlobalTreeConnectionList); 995 INIT_LIST_HEAD(&GlobalTreeConnectionList);
@@ -1095,19 +1090,15 @@ init_cifs(void)
1095 out_destroy_inodecache: 1090 out_destroy_inodecache:
1096 cifs_destroy_inodecache(); 1091 cifs_destroy_inodecache();
1097 out_clean_proc: 1092 out_clean_proc:
1098#ifdef CONFIG_PROC_FS
1099 cifs_proc_clean(); 1093 cifs_proc_clean();
1100#endif
1101 return rc; 1094 return rc;
1102} 1095}
1103 1096
1104static void __exit 1097static void __exit
1105exit_cifs(void) 1098exit_cifs(void)
1106{ 1099{
1107 cFYI(0, ("exit_cifs")); 1100 cFYI(DBG2, ("exit_cifs"));
1108#ifdef CONFIG_PROC_FS
1109 cifs_proc_clean(); 1101 cifs_proc_clean();
1110#endif
1111#ifdef CONFIG_CIFS_DFS_UPCALL 1102#ifdef CONFIG_CIFS_DFS_UPCALL
1112 unregister_key_type(&key_type_dns_resolver); 1103 unregister_key_type(&key_type_dns_resolver);
1113#endif 1104#endif
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 5d32d8ddc82e..69a2e1942542 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -454,7 +454,7 @@ struct dir_notify_req {
454 454
455struct dfs_info3_param { 455struct dfs_info3_param {
456 int flags; /* DFSREF_REFERRAL_SERVER, DFSREF_STORAGE_SERVER*/ 456 int flags; /* DFSREF_REFERRAL_SERVER, DFSREF_STORAGE_SERVER*/
457 int PathConsumed; 457 int path_consumed;
458 int server_type; 458 int server_type;
459 int ref_flag; 459 int ref_flag;
460 char *path_name; 460 char *path_name;
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 2f09f565a3d9..0af63e6b426b 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -53,11 +53,11 @@ extern int SendReceiveNoRsp(const unsigned int xid, struct cifsSesInfo *ses,
53extern int SendReceive2(const unsigned int /* xid */ , struct cifsSesInfo *, 53extern int SendReceive2(const unsigned int /* xid */ , struct cifsSesInfo *,
54 struct kvec *, int /* nvec to send */, 54 struct kvec *, int /* nvec to send */,
55 int * /* type of buf returned */ , const int flags); 55 int * /* type of buf returned */ , const int flags);
56extern int SendReceiveBlockingLock(const unsigned int /* xid */ , 56extern int SendReceiveBlockingLock(const unsigned int xid,
57 struct cifsTconInfo *, 57 struct cifsTconInfo *ptcon,
58 struct smb_hdr * /* input */ , 58 struct smb_hdr *in_buf ,
59 struct smb_hdr * /* out */ , 59 struct smb_hdr *out_buf,
60 int * /* bytes returned */); 60 int *bytes_returned);
61extern int checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length); 61extern int checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length);
62extern int is_valid_oplock_break(struct smb_hdr *smb, struct TCP_Server_Info *); 62extern int is_valid_oplock_break(struct smb_hdr *smb, struct TCP_Server_Info *);
63extern int is_size_safe_to_change(struct cifsInodeInfo *, __u64 eof); 63extern int is_size_safe_to_change(struct cifsInodeInfo *, __u64 eof);
@@ -84,7 +84,7 @@ extern __u16 GetNextMid(struct TCP_Server_Info *server);
84extern struct oplock_q_entry *AllocOplockQEntry(struct inode *, u16, 84extern struct oplock_q_entry *AllocOplockQEntry(struct inode *, u16,
85 struct cifsTconInfo *); 85 struct cifsTconInfo *);
86extern void DeleteOplockQEntry(struct oplock_q_entry *); 86extern void DeleteOplockQEntry(struct oplock_q_entry *);
87extern struct timespec cifs_NTtimeToUnix(u64 /* utc nanoseconds since 1601 */ ); 87extern struct timespec cifs_NTtimeToUnix(u64 utc_nanoseconds_since_1601);
88extern u64 cifs_UnixTimeToNT(struct timespec); 88extern u64 cifs_UnixTimeToNT(struct timespec);
89extern __le64 cnvrtDosCifsTm(__u16 date, __u16 time); 89extern __le64 cnvrtDosCifsTm(__u16 date, __u16 time);
90extern struct timespec cnvrtDosUnixTm(__u16 date, __u16 time); 90extern struct timespec cnvrtDosUnixTm(__u16 date, __u16 time);
@@ -104,7 +104,11 @@ extern int cifs_mount(struct super_block *, struct cifs_sb_info *, char *,
104extern int cifs_umount(struct super_block *, struct cifs_sb_info *); 104extern int cifs_umount(struct super_block *, struct cifs_sb_info *);
105#ifdef CONFIG_CIFS_DFS_UPCALL 105#ifdef CONFIG_CIFS_DFS_UPCALL
106extern void dfs_shrink_umount_helper(struct vfsmount *vfsmnt); 106extern void dfs_shrink_umount_helper(struct vfsmount *vfsmnt);
107#endif 107#else
108static inline void dfs_shrink_umount_helper(struct vfsmount *vfsmnt)
109{
110}
111#endif /* DFS_UPCALL */
108void cifs_proc_init(void); 112void cifs_proc_init(void);
109void cifs_proc_clean(void); 113void cifs_proc_clean(void);
110 114
@@ -175,11 +179,11 @@ extern int CIFSSMBQFSPosixInfo(const int xid, struct cifsTconInfo *tcon,
175 struct kstatfs *FSData); 179 struct kstatfs *FSData);
176 180
177extern int CIFSSMBSetTimes(const int xid, struct cifsTconInfo *tcon, 181extern int CIFSSMBSetTimes(const int xid, struct cifsTconInfo *tcon,
178 const char *fileName, const FILE_BASIC_INFO * data, 182 const char *fileName, const FILE_BASIC_INFO *data,
179 const struct nls_table *nls_codepage, 183 const struct nls_table *nls_codepage,
180 int remap_special_chars); 184 int remap_special_chars);
181extern int CIFSSMBSetFileTimes(const int xid, struct cifsTconInfo *tcon, 185extern int CIFSSMBSetFileTimes(const int xid, struct cifsTconInfo *tcon,
182 const FILE_BASIC_INFO * data, __u16 fid); 186 const FILE_BASIC_INFO *data, __u16 fid);
183#if 0 187#if 0
184extern int CIFSSMBSetAttrLegacy(int xid, struct cifsTconInfo *tcon, 188extern int CIFSSMBSetAttrLegacy(int xid, struct cifsTconInfo *tcon,
185 char *fileName, __u16 dos_attributes, 189 char *fileName, __u16 dos_attributes,
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 9409524e4bf8..30bbe448e260 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * fs/cifs/cifssmb.c 2 * fs/cifs/cifssmb.c
3 * 3 *
4 * Copyright (C) International Business Machines Corp., 2002,2007 4 * Copyright (C) International Business Machines Corp., 2002,2008
5 * Author(s): Steve French (sfrench@us.ibm.com) 5 * Author(s): Steve French (sfrench@us.ibm.com)
6 * 6 *
7 * Contains the routines for constructing the SMB PDUs themselves 7 * Contains the routines for constructing the SMB PDUs themselves
@@ -102,10 +102,12 @@ static void mark_open_files_invalid(struct cifsTconInfo *pTcon)
102 to this tcon */ 102 to this tcon */
103} 103}
104 104
105/* If the return code is zero, this function must fill in request_buf pointer */ 105/* Allocate and return pointer to an SMB request buffer, and set basic
106 SMB information in the SMB header. If the return code is zero, this
107 function must have filled in request_buf pointer */
106static int 108static int
107small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon, 109small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
108 void **request_buf /* returned */) 110 void **request_buf)
109{ 111{
110 int rc = 0; 112 int rc = 0;
111 113
@@ -363,7 +365,7 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
363 *response_buf = *request_buf; 365 *response_buf = *request_buf;
364 366
365 header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon, 367 header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon,
366 wct /*wct */ ); 368 wct);
367 369
368 if (tcon != NULL) 370 if (tcon != NULL)
369 cifs_stats_inc(&tcon->num_smbs_sent); 371 cifs_stats_inc(&tcon->num_smbs_sent);
@@ -523,7 +525,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
523 if (remain >= (MIN_TZ_ADJ / 2)) 525 if (remain >= (MIN_TZ_ADJ / 2))
524 result += MIN_TZ_ADJ; 526 result += MIN_TZ_ADJ;
525 if (val < 0) 527 if (val < 0)
526 result = - result; 528 result = -result;
527 server->timeAdj = result; 529 server->timeAdj = result;
528 } else { 530 } else {
529 server->timeAdj = (int)tmp; 531 server->timeAdj = (int)tmp;
@@ -600,7 +602,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
600 server->maxBuf = min(le32_to_cpu(pSMBr->MaxBufferSize), 602 server->maxBuf = min(le32_to_cpu(pSMBr->MaxBufferSize),
601 (__u32) CIFSMaxBufSize + MAX_CIFS_HDR_SIZE); 603 (__u32) CIFSMaxBufSize + MAX_CIFS_HDR_SIZE);
602 server->maxRw = le32_to_cpu(pSMBr->MaxRawSize); 604 server->maxRw = le32_to_cpu(pSMBr->MaxRawSize);
603 cFYI(0, ("Max buf = %d", ses->server->maxBuf)); 605 cFYI(DBG2, ("Max buf = %d", ses->server->maxBuf));
604 GETU32(ses->server->sessid) = le32_to_cpu(pSMBr->SessionKey); 606 GETU32(ses->server->sessid) = le32_to_cpu(pSMBr->SessionKey);
605 server->capabilities = le32_to_cpu(pSMBr->Capabilities); 607 server->capabilities = le32_to_cpu(pSMBr->Capabilities);
606 server->timeAdj = (int)(__s16)le16_to_cpu(pSMBr->ServerTimeZone); 608 server->timeAdj = (int)(__s16)le16_to_cpu(pSMBr->ServerTimeZone);
@@ -868,9 +870,8 @@ PsxDelete:
868 pSMB->ByteCount = cpu_to_le16(byte_count); 870 pSMB->ByteCount = cpu_to_le16(byte_count);
869 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 871 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
870 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 872 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
871 if (rc) { 873 if (rc)
872 cFYI(1, ("Posix delete returned %d", rc)); 874 cFYI(1, ("Posix delete returned %d", rc));
873 }
874 cifs_buf_release(pSMB); 875 cifs_buf_release(pSMB);
875 876
876 cifs_stats_inc(&tcon->num_deletes); 877 cifs_stats_inc(&tcon->num_deletes);
@@ -916,9 +917,8 @@ DelFileRetry:
916 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 917 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
917 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 918 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
918 cifs_stats_inc(&tcon->num_deletes); 919 cifs_stats_inc(&tcon->num_deletes);
919 if (rc) { 920 if (rc)
920 cFYI(1, ("Error in RMFile = %d", rc)); 921 cFYI(1, ("Error in RMFile = %d", rc));
921 }
922 922
923 cifs_buf_release(pSMB); 923 cifs_buf_release(pSMB);
924 if (rc == -EAGAIN) 924 if (rc == -EAGAIN)
@@ -961,9 +961,8 @@ RmDirRetry:
961 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 961 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
962 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 962 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
963 cifs_stats_inc(&tcon->num_rmdirs); 963 cifs_stats_inc(&tcon->num_rmdirs);
964 if (rc) { 964 if (rc)
965 cFYI(1, ("Error in RMDir = %d", rc)); 965 cFYI(1, ("Error in RMDir = %d", rc));
966 }
967 966
968 cifs_buf_release(pSMB); 967 cifs_buf_release(pSMB);
969 if (rc == -EAGAIN) 968 if (rc == -EAGAIN)
@@ -1005,9 +1004,8 @@ MkDirRetry:
1005 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 1004 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
1006 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 1005 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
1007 cifs_stats_inc(&tcon->num_mkdirs); 1006 cifs_stats_inc(&tcon->num_mkdirs);
1008 if (rc) { 1007 if (rc)
1009 cFYI(1, ("Error in Mkdir = %d", rc)); 1008 cFYI(1, ("Error in Mkdir = %d", rc));
1010 }
1011 1009
1012 cifs_buf_release(pSMB); 1010 cifs_buf_release(pSMB);
1013 if (rc == -EAGAIN) 1011 if (rc == -EAGAIN)
@@ -1017,7 +1015,7 @@ MkDirRetry:
1017 1015
1018int 1016int
1019CIFSPOSIXCreate(const int xid, struct cifsTconInfo *tcon, __u32 posix_flags, 1017CIFSPOSIXCreate(const int xid, struct cifsTconInfo *tcon, __u32 posix_flags,
1020 __u64 mode, __u16 * netfid, FILE_UNIX_BASIC_INFO *pRetData, 1018 __u64 mode, __u16 *netfid, FILE_UNIX_BASIC_INFO *pRetData,
1021 __u32 *pOplock, const char *name, 1019 __u32 *pOplock, const char *name,
1022 const struct nls_table *nls_codepage, int remap) 1020 const struct nls_table *nls_codepage, int remap)
1023{ 1021{
@@ -1027,8 +1025,8 @@ CIFSPOSIXCreate(const int xid, struct cifsTconInfo *tcon, __u32 posix_flags,
1027 int rc = 0; 1025 int rc = 0;
1028 int bytes_returned = 0; 1026 int bytes_returned = 0;
1029 __u16 params, param_offset, offset, byte_count, count; 1027 __u16 params, param_offset, offset, byte_count, count;
1030 OPEN_PSX_REQ * pdata; 1028 OPEN_PSX_REQ *pdata;
1031 OPEN_PSX_RSP * psx_rsp; 1029 OPEN_PSX_RSP *psx_rsp;
1032 1030
1033 cFYI(1, ("In POSIX Create")); 1031 cFYI(1, ("In POSIX Create"));
1034PsxCreat: 1032PsxCreat:
@@ -1110,9 +1108,7 @@ PsxCreat:
1110 /* check to make sure response data is there */ 1108 /* check to make sure response data is there */
1111 if (psx_rsp->ReturnedLevel != cpu_to_le16(SMB_QUERY_FILE_UNIX_BASIC)) { 1109 if (psx_rsp->ReturnedLevel != cpu_to_le16(SMB_QUERY_FILE_UNIX_BASIC)) {
1112 pRetData->Type = cpu_to_le32(-1); /* unknown */ 1110 pRetData->Type = cpu_to_le32(-1); /* unknown */
1113#ifdef CONFIG_CIFS_DEBUG2 1111 cFYI(DBG2, ("unknown type"));
1114 cFYI(1, ("unknown type"));
1115#endif
1116 } else { 1112 } else {
1117 if (pSMBr->ByteCount < sizeof(OPEN_PSX_RSP) 1113 if (pSMBr->ByteCount < sizeof(OPEN_PSX_RSP)
1118 + sizeof(FILE_UNIX_BASIC_INFO)) { 1114 + sizeof(FILE_UNIX_BASIC_INFO)) {
@@ -1169,8 +1165,8 @@ static __u16 convert_disposition(int disposition)
1169int 1165int
1170SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon, 1166SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon,
1171 const char *fileName, const int openDisposition, 1167 const char *fileName, const int openDisposition,
1172 const int access_flags, const int create_options, __u16 * netfid, 1168 const int access_flags, const int create_options, __u16 *netfid,
1173 int *pOplock, FILE_ALL_INFO * pfile_info, 1169 int *pOplock, FILE_ALL_INFO *pfile_info,
1174 const struct nls_table *nls_codepage, int remap) 1170 const struct nls_table *nls_codepage, int remap)
1175{ 1171{
1176 int rc = -EACCES; 1172 int rc = -EACCES;
@@ -1221,8 +1217,8 @@ OldOpenRetry:
1221 1217
1222 if (create_options & CREATE_OPTION_SPECIAL) 1218 if (create_options & CREATE_OPTION_SPECIAL)
1223 pSMB->FileAttributes = cpu_to_le16(ATTR_SYSTEM); 1219 pSMB->FileAttributes = cpu_to_le16(ATTR_SYSTEM);
1224 else 1220 else /* BB FIXME BB */
1225 pSMB->FileAttributes = cpu_to_le16(0/*ATTR_NORMAL*/); /* BB FIXME */ 1221 pSMB->FileAttributes = cpu_to_le16(0/*ATTR_NORMAL*/);
1226 1222
1227 /* if ((omode & S_IWUGO) == 0) 1223 /* if ((omode & S_IWUGO) == 0)
1228 pSMB->FileAttributes |= cpu_to_le32(ATTR_READONLY);*/ 1224 pSMB->FileAttributes |= cpu_to_le32(ATTR_READONLY);*/
@@ -1284,8 +1280,8 @@ OldOpenRetry:
1284int 1280int
1285CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon, 1281CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon,
1286 const char *fileName, const int openDisposition, 1282 const char *fileName, const int openDisposition,
1287 const int access_flags, const int create_options, __u16 * netfid, 1283 const int access_flags, const int create_options, __u16 *netfid,
1288 int *pOplock, FILE_ALL_INFO * pfile_info, 1284 int *pOplock, FILE_ALL_INFO *pfile_info,
1289 const struct nls_table *nls_codepage, int remap) 1285 const struct nls_table *nls_codepage, int remap)
1290{ 1286{
1291 int rc = -EACCES; 1287 int rc = -EACCES;
@@ -1556,9 +1552,9 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
1556 } /* else setting file size with write of zero bytes */ 1552 } /* else setting file size with write of zero bytes */
1557 if (wct == 14) 1553 if (wct == 14)
1558 byte_count = bytes_sent + 1; /* pad */ 1554 byte_count = bytes_sent + 1; /* pad */
1559 else /* wct == 12 */ { 1555 else /* wct == 12 */
1560 byte_count = bytes_sent + 5; /* bigger pad, smaller smb hdr */ 1556 byte_count = bytes_sent + 5; /* bigger pad, smaller smb hdr */
1561 } 1557
1562 pSMB->DataLengthLow = cpu_to_le16(bytes_sent & 0xFFFF); 1558 pSMB->DataLengthLow = cpu_to_le16(bytes_sent & 0xFFFF);
1563 pSMB->DataLengthHigh = cpu_to_le16(bytes_sent >> 16); 1559 pSMB->DataLengthHigh = cpu_to_le16(bytes_sent >> 16);
1564 pSMB->hdr.smb_buf_length += byte_count; 1560 pSMB->hdr.smb_buf_length += byte_count;
@@ -1663,7 +1659,7 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
1663 rc = -EIO; 1659 rc = -EIO;
1664 *nbytes = 0; 1660 *nbytes = 0;
1665 } else { 1661 } else {
1666 WRITE_RSP * pSMBr = (WRITE_RSP *)iov[0].iov_base; 1662 WRITE_RSP *pSMBr = (WRITE_RSP *)iov[0].iov_base;
1667 *nbytes = le16_to_cpu(pSMBr->CountHigh); 1663 *nbytes = le16_to_cpu(pSMBr->CountHigh);
1668 *nbytes = (*nbytes) << 16; 1664 *nbytes = (*nbytes) << 16;
1669 *nbytes += le16_to_cpu(pSMBr->Count); 1665 *nbytes += le16_to_cpu(pSMBr->Count);
@@ -1744,9 +1740,8 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
1744 /* SMB buffer freed by function above */ 1740 /* SMB buffer freed by function above */
1745 } 1741 }
1746 cifs_stats_inc(&tcon->num_locks); 1742 cifs_stats_inc(&tcon->num_locks);
1747 if (rc) { 1743 if (rc)
1748 cFYI(1, ("Send error in Lock = %d", rc)); 1744 cFYI(1, ("Send error in Lock = %d", rc));
1749 }
1750 1745
1751 /* Note: On -EAGAIN error only caller can retry on handle based calls 1746 /* Note: On -EAGAIN error only caller can retry on handle based calls
1752 since file handle passed in no longer valid */ 1747 since file handle passed in no longer valid */
@@ -1791,7 +1786,7 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
1791 1786
1792 count = sizeof(struct cifs_posix_lock); 1787 count = sizeof(struct cifs_posix_lock);
1793 pSMB->MaxParameterCount = cpu_to_le16(2); 1788 pSMB->MaxParameterCount = cpu_to_le16(2);
1794 pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB PDU from sess */ 1789 pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB from sess */
1795 pSMB->SetupCount = 1; 1790 pSMB->SetupCount = 1;
1796 pSMB->Reserved3 = 0; 1791 pSMB->Reserved3 = 0;
1797 if (get_flag) 1792 if (get_flag)
@@ -1972,9 +1967,8 @@ renameRetry:
1972 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 1967 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
1973 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 1968 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
1974 cifs_stats_inc(&tcon->num_renames); 1969 cifs_stats_inc(&tcon->num_renames);
1975 if (rc) { 1970 if (rc)
1976 cFYI(1, ("Send error in rename = %d", rc)); 1971 cFYI(1, ("Send error in rename = %d", rc));
1977 }
1978 1972
1979 cifs_buf_release(pSMB); 1973 cifs_buf_release(pSMB);
1980 1974
@@ -2016,7 +2010,7 @@ int CIFSSMBRenameOpenFile(const int xid, struct cifsTconInfo *pTcon,
2016 data_offset = (char *) (&pSMB->hdr.Protocol) + offset; 2010 data_offset = (char *) (&pSMB->hdr.Protocol) + offset;
2017 rename_info = (struct set_file_rename *) data_offset; 2011 rename_info = (struct set_file_rename *) data_offset;
2018 pSMB->MaxParameterCount = cpu_to_le16(2); 2012 pSMB->MaxParameterCount = cpu_to_le16(2);
2019 pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB PDU from sess */ 2013 pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB from sess */
2020 pSMB->SetupCount = 1; 2014 pSMB->SetupCount = 1;
2021 pSMB->Reserved3 = 0; 2015 pSMB->Reserved3 = 0;
2022 pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FILE_INFORMATION); 2016 pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FILE_INFORMATION);
@@ -2052,9 +2046,8 @@ int CIFSSMBRenameOpenFile(const int xid, struct cifsTconInfo *pTcon,
2052 rc = SendReceive(xid, pTcon->ses, (struct smb_hdr *) pSMB, 2046 rc = SendReceive(xid, pTcon->ses, (struct smb_hdr *) pSMB,
2053 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 2047 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
2054 cifs_stats_inc(&pTcon->num_t2renames); 2048 cifs_stats_inc(&pTcon->num_t2renames);
2055 if (rc) { 2049 if (rc)
2056 cFYI(1, ("Send error in Rename (by file handle) = %d", rc)); 2050 cFYI(1, ("Send error in Rename (by file handle) = %d", rc));
2057 }
2058 2051
2059 cifs_buf_release(pSMB); 2052 cifs_buf_release(pSMB);
2060 2053
@@ -2211,9 +2204,8 @@ createSymLinkRetry:
2211 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 2204 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
2212 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 2205 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
2213 cifs_stats_inc(&tcon->num_symlinks); 2206 cifs_stats_inc(&tcon->num_symlinks);
2214 if (rc) { 2207 if (rc)
2215 cFYI(1, ("Send error in SetPathInfo create symlink = %d", rc)); 2208 cFYI(1, ("Send error in SetPathInfo create symlink = %d", rc));
2216 }
2217 2209
2218 if (pSMB) 2210 if (pSMB)
2219 cifs_buf_release(pSMB); 2211 cifs_buf_release(pSMB);
@@ -2299,9 +2291,8 @@ createHardLinkRetry:
2299 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 2291 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
2300 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 2292 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
2301 cifs_stats_inc(&tcon->num_hardlinks); 2293 cifs_stats_inc(&tcon->num_hardlinks);
2302 if (rc) { 2294 if (rc)
2303 cFYI(1, ("Send error in SetPathInfo (hard link) = %d", rc)); 2295 cFYI(1, ("Send error in SetPathInfo (hard link) = %d", rc));
2304 }
2305 2296
2306 cifs_buf_release(pSMB); 2297 cifs_buf_release(pSMB);
2307 if (rc == -EAGAIN) 2298 if (rc == -EAGAIN)
@@ -2370,9 +2361,9 @@ winCreateHardLinkRetry:
2370 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 2361 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
2371 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 2362 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
2372 cifs_stats_inc(&tcon->num_hardlinks); 2363 cifs_stats_inc(&tcon->num_hardlinks);
2373 if (rc) { 2364 if (rc)
2374 cFYI(1, ("Send error in hard link (NT rename) = %d", rc)); 2365 cFYI(1, ("Send error in hard link (NT rename) = %d", rc));
2375 } 2366
2376 cifs_buf_release(pSMB); 2367 cifs_buf_release(pSMB);
2377 if (rc == -EAGAIN) 2368 if (rc == -EAGAIN)
2378 goto winCreateHardLinkRetry; 2369 goto winCreateHardLinkRetry;
@@ -2968,9 +2959,8 @@ setAclRetry:
2968 pSMB->ByteCount = cpu_to_le16(byte_count); 2959 pSMB->ByteCount = cpu_to_le16(byte_count);
2969 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 2960 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
2970 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 2961 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
2971 if (rc) { 2962 if (rc)
2972 cFYI(1, ("Set POSIX ACL returned %d", rc)); 2963 cFYI(1, ("Set POSIX ACL returned %d", rc));
2973 }
2974 2964
2975setACLerrorExit: 2965setACLerrorExit:
2976 cifs_buf_release(pSMB); 2966 cifs_buf_release(pSMB);
@@ -2982,7 +2972,7 @@ setACLerrorExit:
2982/* BB fix tabs in this function FIXME BB */ 2972/* BB fix tabs in this function FIXME BB */
2983int 2973int
2984CIFSGetExtAttr(const int xid, struct cifsTconInfo *tcon, 2974CIFSGetExtAttr(const int xid, struct cifsTconInfo *tcon,
2985 const int netfid, __u64 * pExtAttrBits, __u64 *pMask) 2975 const int netfid, __u64 *pExtAttrBits, __u64 *pMask)
2986{ 2976{
2987 int rc = 0; 2977 int rc = 0;
2988 struct smb_t2_qfi_req *pSMB = NULL; 2978 struct smb_t2_qfi_req *pSMB = NULL;
@@ -3000,7 +2990,7 @@ GetExtAttrRetry:
3000 if (rc) 2990 if (rc)
3001 return rc; 2991 return rc;
3002 2992
3003 params = 2 /* level */ +2 /* fid */; 2993 params = 2 /* level */ + 2 /* fid */;
3004 pSMB->t2.TotalDataCount = 0; 2994 pSMB->t2.TotalDataCount = 0;
3005 pSMB->t2.MaxParameterCount = cpu_to_le16(4); 2995 pSMB->t2.MaxParameterCount = cpu_to_le16(4);
3006 /* BB find exact max data count below from sess structure BB */ 2996 /* BB find exact max data count below from sess structure BB */
@@ -3071,7 +3061,7 @@ CIFSSMBGetCIFSACL(const int xid, struct cifsTconInfo *tcon, __u16 fid,
3071{ 3061{
3072 int rc = 0; 3062 int rc = 0;
3073 int buf_type = 0; 3063 int buf_type = 0;
3074 QUERY_SEC_DESC_REQ * pSMB; 3064 QUERY_SEC_DESC_REQ *pSMB;
3075 struct kvec iov[1]; 3065 struct kvec iov[1];
3076 3066
3077 cFYI(1, ("GetCifsACL")); 3067 cFYI(1, ("GetCifsACL"));
@@ -3101,7 +3091,7 @@ CIFSSMBGetCIFSACL(const int xid, struct cifsTconInfo *tcon, __u16 fid,
3101 if (rc) { 3091 if (rc) {
3102 cFYI(1, ("Send error in QuerySecDesc = %d", rc)); 3092 cFYI(1, ("Send error in QuerySecDesc = %d", rc));
3103 } else { /* decode response */ 3093 } else { /* decode response */
3104 __le32 * parm; 3094 __le32 *parm;
3105 __u32 parm_len; 3095 __u32 parm_len;
3106 __u32 acl_len; 3096 __u32 acl_len;
3107 struct smb_com_ntransact_rsp *pSMBr; 3097 struct smb_com_ntransact_rsp *pSMBr;
@@ -3230,8 +3220,8 @@ int SMBQueryInformation(const int xid, struct cifsTconInfo *tcon,
3230 FILE_ALL_INFO *pFinfo, 3220 FILE_ALL_INFO *pFinfo,
3231 const struct nls_table *nls_codepage, int remap) 3221 const struct nls_table *nls_codepage, int remap)
3232{ 3222{
3233 QUERY_INFORMATION_REQ * pSMB; 3223 QUERY_INFORMATION_REQ *pSMB;
3234 QUERY_INFORMATION_RSP * pSMBr; 3224 QUERY_INFORMATION_RSP *pSMBr;
3235 int rc = 0; 3225 int rc = 0;
3236 int bytes_returned; 3226 int bytes_returned;
3237 int name_len; 3227 int name_len;
@@ -3263,9 +3253,11 @@ QInfRetry:
3263 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 3253 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
3264 if (rc) { 3254 if (rc) {
3265 cFYI(1, ("Send error in QueryInfo = %d", rc)); 3255 cFYI(1, ("Send error in QueryInfo = %d", rc));
3266 } else if (pFinfo) { /* decode response */ 3256 } else if (pFinfo) {
3267 struct timespec ts; 3257 struct timespec ts;
3268 __u32 time = le32_to_cpu(pSMBr->last_write_time); 3258 __u32 time = le32_to_cpu(pSMBr->last_write_time);
3259
3260 /* decode response */
3269 /* BB FIXME - add time zone adjustment BB */ 3261 /* BB FIXME - add time zone adjustment BB */
3270 memset(pFinfo, 0, sizeof(FILE_ALL_INFO)); 3262 memset(pFinfo, 0, sizeof(FILE_ALL_INFO));
3271 ts.tv_nsec = 0; 3263 ts.tv_nsec = 0;
@@ -3296,7 +3288,7 @@ QInfRetry:
3296int 3288int
3297CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon, 3289CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon,
3298 const unsigned char *searchName, 3290 const unsigned char *searchName,
3299 FILE_ALL_INFO * pFindData, 3291 FILE_ALL_INFO *pFindData,
3300 int legacy /* old style infolevel */, 3292 int legacy /* old style infolevel */,
3301 const struct nls_table *nls_codepage, int remap) 3293 const struct nls_table *nls_codepage, int remap)
3302{ 3294{
@@ -3371,10 +3363,12 @@ QPathInfoRetry:
3371 else if (pFindData) { 3363 else if (pFindData) {
3372 int size; 3364 int size;
3373 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 3365 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
3374 if (legacy) /* we do not read the last field, EAsize, 3366
3375 fortunately since it varies by subdialect 3367 /* On legacy responses we do not read the last field,
3376 and on Set vs. Get, is two bytes or 4 3368 EAsize, fortunately since it varies by subdialect and
3377 bytes depending but we don't care here */ 3369 also note it differs on Set vs. Get, ie two bytes or 4
3370 bytes depending but we don't care here */
3371 if (legacy)
3378 size = sizeof(FILE_INFO_STANDARD); 3372 size = sizeof(FILE_INFO_STANDARD);
3379 else 3373 else
3380 size = sizeof(FILE_ALL_INFO); 3374 size = sizeof(FILE_ALL_INFO);
@@ -3476,85 +3470,6 @@ UnixQPathInfoRetry:
3476 return rc; 3470 return rc;
3477} 3471}
3478 3472
3479#if 0 /* function unused at present */
3480int CIFSFindSingle(const int xid, struct cifsTconInfo *tcon,
3481 const char *searchName, FILE_ALL_INFO * findData,
3482 const struct nls_table *nls_codepage)
3483{
3484/* level 257 SMB_ */
3485 TRANSACTION2_FFIRST_REQ *pSMB = NULL;
3486 TRANSACTION2_FFIRST_RSP *pSMBr = NULL;
3487 int rc = 0;
3488 int bytes_returned;
3489 int name_len;
3490 __u16 params, byte_count;
3491
3492 cFYI(1, ("In FindUnique"));
3493findUniqueRetry:
3494 rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
3495 (void **) &pSMBr);
3496 if (rc)
3497 return rc;
3498
3499 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
3500 name_len =
3501 cifsConvertToUCS((__le16 *) pSMB->FileName, searchName,
3502 PATH_MAX, nls_codepage);
3503 name_len++; /* trailing null */
3504 name_len *= 2;
3505 } else { /* BB improve the check for buffer overruns BB */
3506 name_len = strnlen(searchName, PATH_MAX);
3507 name_len++; /* trailing null */
3508 strncpy(pSMB->FileName, searchName, name_len);
3509 }
3510
3511 params = 12 + name_len /* includes null */ ;
3512 pSMB->TotalDataCount = 0; /* no EAs */
3513 pSMB->MaxParameterCount = cpu_to_le16(2);
3514 pSMB->MaxDataCount = cpu_to_le16(4000); /* BB find exact max SMB PDU from sess structure BB */
3515 pSMB->MaxSetupCount = 0;
3516 pSMB->Reserved = 0;
3517 pSMB->Flags = 0;
3518 pSMB->Timeout = 0;
3519 pSMB->Reserved2 = 0;
3520 pSMB->ParameterOffset = cpu_to_le16(
3521 offsetof(struct smb_com_transaction2_ffirst_req, InformationLevel)-4);
3522 pSMB->DataCount = 0;
3523 pSMB->DataOffset = 0;
3524 pSMB->SetupCount = 1; /* one byte, no need to le convert */
3525 pSMB->Reserved3 = 0;
3526 pSMB->SubCommand = cpu_to_le16(TRANS2_FIND_FIRST);
3527 byte_count = params + 1 /* pad */ ;
3528 pSMB->TotalParameterCount = cpu_to_le16(params);
3529 pSMB->ParameterCount = pSMB->TotalParameterCount;
3530 pSMB->SearchAttributes =
3531 cpu_to_le16(ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM |
3532 ATTR_DIRECTORY);
3533 pSMB->SearchCount = cpu_to_le16(16); /* BB increase */
3534 pSMB->SearchFlags = cpu_to_le16(1);
3535 pSMB->InformationLevel = cpu_to_le16(SMB_FIND_FILE_DIRECTORY_INFO);
3536 pSMB->SearchStorageType = 0; /* BB what should we set this to? BB */
3537 pSMB->hdr.smb_buf_length += byte_count;
3538 pSMB->ByteCount = cpu_to_le16(byte_count);
3539
3540 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
3541 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
3542
3543 if (rc) {
3544 cFYI(1, ("Send error in FindFileDirInfo = %d", rc));
3545 } else { /* decode response */
3546 cifs_stats_inc(&tcon->num_ffirst);
3547 /* BB fill in */
3548 }
3549
3550 cifs_buf_release(pSMB);
3551 if (rc == -EAGAIN)
3552 goto findUniqueRetry;
3553
3554 return rc;
3555}
3556#endif /* end unused (temporarily) function */
3557
3558/* xid, tcon, searchName and codepage are input parms, rest are returned */ 3473/* xid, tcon, searchName and codepage are input parms, rest are returned */
3559int 3474int
3560CIFSFindFirst(const int xid, struct cifsTconInfo *tcon, 3475CIFSFindFirst(const int xid, struct cifsTconInfo *tcon,
@@ -3566,7 +3481,7 @@ CIFSFindFirst(const int xid, struct cifsTconInfo *tcon,
3566/* level 257 SMB_ */ 3481/* level 257 SMB_ */
3567 TRANSACTION2_FFIRST_REQ *pSMB = NULL; 3482 TRANSACTION2_FFIRST_REQ *pSMB = NULL;
3568 TRANSACTION2_FFIRST_RSP *pSMBr = NULL; 3483 TRANSACTION2_FFIRST_RSP *pSMBr = NULL;
3569 T2_FFIRST_RSP_PARMS * parms; 3484 T2_FFIRST_RSP_PARMS *parms;
3570 int rc = 0; 3485 int rc = 0;
3571 int bytes_returned = 0; 3486 int bytes_returned = 0;
3572 int name_len; 3487 int name_len;
@@ -3697,7 +3612,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
3697{ 3612{
3698 TRANSACTION2_FNEXT_REQ *pSMB = NULL; 3613 TRANSACTION2_FNEXT_REQ *pSMB = NULL;
3699 TRANSACTION2_FNEXT_RSP *pSMBr = NULL; 3614 TRANSACTION2_FNEXT_RSP *pSMBr = NULL;
3700 T2_FNEXT_RSP_PARMS * parms; 3615 T2_FNEXT_RSP_PARMS *parms;
3701 char *response_data; 3616 char *response_data;
3702 int rc = 0; 3617 int rc = 0;
3703 int bytes_returned, name_len; 3618 int bytes_returned, name_len;
@@ -3836,9 +3751,9 @@ CIFSFindClose(const int xid, struct cifsTconInfo *tcon,
3836 pSMB->FileID = searchHandle; 3751 pSMB->FileID = searchHandle;
3837 pSMB->ByteCount = 0; 3752 pSMB->ByteCount = 0;
3838 rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *) pSMB, 0); 3753 rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *) pSMB, 0);
3839 if (rc) { 3754 if (rc)
3840 cERROR(1, ("Send error in FindClose = %d", rc)); 3755 cERROR(1, ("Send error in FindClose = %d", rc));
3841 } 3756
3842 cifs_stats_inc(&tcon->num_fclose); 3757 cifs_stats_inc(&tcon->num_fclose);
3843 3758
3844 /* Since session is dead, search handle closed on server already */ 3759 /* Since session is dead, search handle closed on server already */
@@ -3851,7 +3766,7 @@ CIFSFindClose(const int xid, struct cifsTconInfo *tcon,
3851int 3766int
3852CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon, 3767CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon,
3853 const unsigned char *searchName, 3768 const unsigned char *searchName,
3854 __u64 * inode_number, 3769 __u64 *inode_number,
3855 const struct nls_table *nls_codepage, int remap) 3770 const struct nls_table *nls_codepage, int remap)
3856{ 3771{
3857 int rc = 0; 3772 int rc = 0;
@@ -4560,9 +4475,8 @@ SETFSUnixRetry:
4560 cERROR(1, ("Send error in SETFSUnixInfo = %d", rc)); 4475 cERROR(1, ("Send error in SETFSUnixInfo = %d", rc));
4561 } else { /* decode response */ 4476 } else { /* decode response */
4562 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 4477 rc = validate_t2((struct smb_t2_rsp *)pSMBr);
4563 if (rc) { 4478 if (rc)
4564 rc = -EIO; /* bad smb */ 4479 rc = -EIO; /* bad smb */
4565 }
4566 } 4480 }
4567 cifs_buf_release(pSMB); 4481 cifs_buf_release(pSMB);
4568 4482
@@ -4744,9 +4658,8 @@ SetEOFRetry:
4744 pSMB->ByteCount = cpu_to_le16(byte_count); 4658 pSMB->ByteCount = cpu_to_le16(byte_count);
4745 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 4659 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
4746 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 4660 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
4747 if (rc) { 4661 if (rc)
4748 cFYI(1, ("SetPathInfo (file size) returned %d", rc)); 4662 cFYI(1, ("SetPathInfo (file size) returned %d", rc));
4749 }
4750 4663
4751 cifs_buf_release(pSMB); 4664 cifs_buf_release(pSMB);
4752 4665
@@ -4897,9 +4810,8 @@ CIFSSMBSetFileTimes(const int xid, struct cifsTconInfo *tcon,
4897 pSMB->ByteCount = cpu_to_le16(byte_count); 4810 pSMB->ByteCount = cpu_to_le16(byte_count);
4898 memcpy(data_offset, data, sizeof(FILE_BASIC_INFO)); 4811 memcpy(data_offset, data, sizeof(FILE_BASIC_INFO));
4899 rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *) pSMB, 0); 4812 rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *) pSMB, 0);
4900 if (rc) { 4813 if (rc)
4901 cFYI(1, ("Send error in Set Time (SetFileInfo) = %d", rc)); 4814 cFYI(1, ("Send error in Set Time (SetFileInfo) = %d", rc));
4902 }
4903 4815
4904 /* Note: On -EAGAIN error only caller can retry on handle based calls 4816 /* Note: On -EAGAIN error only caller can retry on handle based calls
4905 since file handle passed in no longer valid */ 4817 since file handle passed in no longer valid */
@@ -4975,9 +4887,8 @@ SetTimesRetry:
4975 pSMB->ByteCount = cpu_to_le16(byte_count); 4887 pSMB->ByteCount = cpu_to_le16(byte_count);
4976 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 4888 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
4977 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 4889 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
4978 if (rc) { 4890 if (rc)
4979 cFYI(1, ("SetPathInfo (times) returned %d", rc)); 4891 cFYI(1, ("SetPathInfo (times) returned %d", rc));
4980 }
4981 4892
4982 cifs_buf_release(pSMB); 4893 cifs_buf_release(pSMB);
4983 4894
@@ -5027,9 +4938,8 @@ SetAttrLgcyRetry:
5027 pSMB->ByteCount = cpu_to_le16(name_len + 1); 4938 pSMB->ByteCount = cpu_to_le16(name_len + 1);
5028 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 4939 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
5029 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 4940 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
5030 if (rc) { 4941 if (rc)
5031 cFYI(1, ("Error in LegacySetAttr = %d", rc)); 4942 cFYI(1, ("Error in LegacySetAttr = %d", rc));
5032 }
5033 4943
5034 cifs_buf_release(pSMB); 4944 cifs_buf_release(pSMB);
5035 4945
@@ -5138,9 +5048,8 @@ setPermsRetry:
5138 pSMB->ByteCount = cpu_to_le16(byte_count); 5048 pSMB->ByteCount = cpu_to_le16(byte_count);
5139 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 5049 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
5140 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 5050 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
5141 if (rc) { 5051 if (rc)
5142 cFYI(1, ("SetPathInfo (perms) returned %d", rc)); 5052 cFYI(1, ("SetPathInfo (perms) returned %d", rc));
5143 }
5144 5053
5145 if (pSMB) 5054 if (pSMB)
5146 cifs_buf_release(pSMB); 5055 cifs_buf_release(pSMB);
@@ -5615,9 +5524,8 @@ SetEARetry:
5615 pSMB->ByteCount = cpu_to_le16(byte_count); 5524 pSMB->ByteCount = cpu_to_le16(byte_count);
5616 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 5525 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
5617 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 5526 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
5618 if (rc) { 5527 if (rc)
5619 cFYI(1, ("SetPathInfo (EA) returned %d", rc)); 5528 cFYI(1, ("SetPathInfo (EA) returned %d", rc));
5620 }
5621 5529
5622 cifs_buf_release(pSMB); 5530 cifs_buf_release(pSMB);
5623 5531
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 65d0ba72e78f..8dbfa97cd18c 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1722,8 +1722,15 @@ void reset_cifs_unix_caps(int xid, struct cifsTconInfo *tcon,
1722 originally at mount time */ 1722 originally at mount time */
1723 if ((saved_cap & CIFS_UNIX_POSIX_ACL_CAP) == 0) 1723 if ((saved_cap & CIFS_UNIX_POSIX_ACL_CAP) == 0)
1724 cap &= ~CIFS_UNIX_POSIX_ACL_CAP; 1724 cap &= ~CIFS_UNIX_POSIX_ACL_CAP;
1725 if ((saved_cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) == 0) 1725 if ((saved_cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) == 0) {
1726 if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP)
1727 cERROR(1, ("POSIXPATH support change"));
1726 cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP; 1728 cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP;
1729 } else if ((cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) == 0) {
1730 cERROR(1, ("possible reconnect error"));
1731 cERROR(1,
1732 ("server disabled POSIX path support"));
1733 }
1727 } 1734 }
1728 1735
1729 cap &= CIFS_UNIX_CAP_MASK; 1736 cap &= CIFS_UNIX_CAP_MASK;
@@ -1753,9 +1760,8 @@ void reset_cifs_unix_caps(int xid, struct cifsTconInfo *tcon,
1753 if (sb && (CIFS_SB(sb)->rsize > 127 * 1024)) { 1760 if (sb && (CIFS_SB(sb)->rsize > 127 * 1024)) {
1754 if ((cap & CIFS_UNIX_LARGE_READ_CAP) == 0) { 1761 if ((cap & CIFS_UNIX_LARGE_READ_CAP) == 0) {
1755 CIFS_SB(sb)->rsize = 127 * 1024; 1762 CIFS_SB(sb)->rsize = 127 * 1024;
1756#ifdef CONFIG_CIFS_DEBUG2 1763 cFYI(DBG2,
1757 cFYI(1, ("larger reads not supported by srv")); 1764 ("larger reads not supported by srv"));
1758#endif
1759 } 1765 }
1760 } 1766 }
1761 1767
@@ -1792,6 +1798,26 @@ void reset_cifs_unix_caps(int xid, struct cifsTconInfo *tcon,
1792 } 1798 }
1793} 1799}
1794 1800
1801static void
1802convert_delimiter(char *path, char delim)
1803{
1804 int i;
1805 char old_delim;
1806
1807 if (path == NULL)
1808 return;
1809
1810 if (delim == '/')
1811 old_delim = '\\';
1812 else
1813 old_delim = '/';
1814
1815 for (i = 0; path[i] != '\0'; i++) {
1816 if (path[i] == old_delim)
1817 path[i] = delim;
1818 }
1819}
1820
1795int 1821int
1796cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, 1822cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
1797 char *mount_data, const char *devname) 1823 char *mount_data, const char *devname)
@@ -2057,7 +2083,11 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2057 cifs_sb->prepath = volume_info.prepath; 2083 cifs_sb->prepath = volume_info.prepath;
2058 if (cifs_sb->prepath) { 2084 if (cifs_sb->prepath) {
2059 cifs_sb->prepathlen = strlen(cifs_sb->prepath); 2085 cifs_sb->prepathlen = strlen(cifs_sb->prepath);
2060 cifs_sb->prepath[0] = CIFS_DIR_SEP(cifs_sb); 2086 /* we can not convert the / to \ in the path
2087 separators in the prefixpath yet because we do not
2088 know (until reset_cifs_unix_caps is called later)
2089 whether POSIX PATH CAP is available. We normalize
2090 the / to \ after reset_cifs_unix_caps is called */
2061 volume_info.prepath = NULL; 2091 volume_info.prepath = NULL;
2062 } else 2092 } else
2063 cifs_sb->prepathlen = 0; 2093 cifs_sb->prepathlen = 0;
@@ -2225,11 +2255,15 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2225 else 2255 else
2226 tcon->unix_ext = 0; /* server does not support them */ 2256 tcon->unix_ext = 0; /* server does not support them */
2227 2257
2258 /* convert forward to back slashes in prepath here if needed */
2259 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) == 0)
2260 convert_delimiter(cifs_sb->prepath,
2261 CIFS_DIR_SEP(cifs_sb));
2262
2228 if ((tcon->unix_ext == 0) && (cifs_sb->rsize > (1024 * 127))) { 2263 if ((tcon->unix_ext == 0) && (cifs_sb->rsize > (1024 * 127))) {
2229 cifs_sb->rsize = 1024 * 127; 2264 cifs_sb->rsize = 1024 * 127;
2230#ifdef CONFIG_CIFS_DEBUG2 2265 cFYI(DBG2,
2231 cFYI(1, ("no very large read support, rsize now 127K")); 2266 ("no very large read support, rsize now 127K"));
2232#endif
2233 } 2267 }
2234 if (!(tcon->ses->capabilities & CAP_LARGE_WRITE_X)) 2268 if (!(tcon->ses->capabilities & CAP_LARGE_WRITE_X))
2235 cifs_sb->wsize = min(cifs_sb->wsize, 2269 cifs_sb->wsize = min(cifs_sb->wsize,
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 699ec1198409..4e83b47c4b34 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * vfs operations that deal with dentries 4 * vfs operations that deal with dentries
5 * 5 *
6 * Copyright (C) International Business Machines Corp., 2002,2007 6 * Copyright (C) International Business Machines Corp., 2002,2008
7 * Author(s): Steve French (sfrench@us.ibm.com) 7 * Author(s): Steve French (sfrench@us.ibm.com)
8 * 8 *
9 * This library is free software; you can redistribute it and/or modify 9 * This library is free software; you can redistribute it and/or modify
@@ -111,16 +111,6 @@ cifs_bp_rename_retry:
111 return full_path; 111 return full_path;
112} 112}
113 113
114/* char * build_wildcard_path_from_dentry(struct dentry *direntry)
115{
116 if(full_path == NULL)
117 return full_path;
118
119 full_path[namelen] = '\\';
120 full_path[namelen+1] = '*';
121 full_path[namelen+2] = 0;
122BB remove above eight lines BB */
123
124/* Inode operations in similar order to how they appear in Linux file fs.h */ 114/* Inode operations in similar order to how they appear in Linux file fs.h */
125 115
126int 116int
@@ -171,9 +161,8 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
171 disposition = FILE_OVERWRITE_IF; 161 disposition = FILE_OVERWRITE_IF;
172 else if ((oflags & O_CREAT) == O_CREAT) 162 else if ((oflags & O_CREAT) == O_CREAT)
173 disposition = FILE_OPEN_IF; 163 disposition = FILE_OPEN_IF;
174 else { 164 else
175 cFYI(1, ("Create flag not set in create function")); 165 cFYI(1, ("Create flag not set in create function"));
176 }
177 } 166 }
178 167
179 /* BB add processing to set equivalent of mode - e.g. via CreateX with 168 /* BB add processing to set equivalent of mode - e.g. via CreateX with
@@ -367,7 +356,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
367 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { 356 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) {
368 int oplock = 0; 357 int oplock = 0;
369 u16 fileHandle; 358 u16 fileHandle;
370 FILE_ALL_INFO * buf; 359 FILE_ALL_INFO *buf;
371 360
372 cFYI(1, ("sfu compat create special file")); 361 cFYI(1, ("sfu compat create special file"));
373 362
@@ -534,9 +523,8 @@ cifs_d_revalidate(struct dentry *direntry, struct nameidata *nd)
534 int isValid = 1; 523 int isValid = 1;
535 524
536 if (direntry->d_inode) { 525 if (direntry->d_inode) {
537 if (cifs_revalidate(direntry)) { 526 if (cifs_revalidate(direntry))
538 return 0; 527 return 0;
539 }
540 } else { 528 } else {
541 cFYI(1, ("neg dentry 0x%p name = %s", 529 cFYI(1, ("neg dentry 0x%p name = %s",
542 direntry, direntry->d_name.name)); 530 direntry, direntry->d_name.name));
diff --git a/fs/cifs/dns_resolve.h b/fs/cifs/dns_resolve.h
index 073fdc3db419..966e9288930b 100644
--- a/fs/cifs/dns_resolve.h
+++ b/fs/cifs/dns_resolve.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * fs/cifs/dns_resolve.h -- DNS Resolver upcall management for CIFS DFS 2 * fs/cifs/dns_resolve.h -- DNS Resolver upcall management for CIFS DFS
3 * Handles host name to IP address resolution 3 * Handles host name to IP address resolution
4 * 4 *
5 * Copyright (c) International Business Machines Corp., 2008 5 * Copyright (c) International Business Machines Corp., 2008
6 * Author(s): Steve French (sfrench@us.ibm.com) 6 * Author(s): Steve French (sfrench@us.ibm.com)
7 * 7 *
diff --git a/fs/cifs/fcntl.c b/fs/cifs/fcntl.c
index 995474c90885..7d1d5aa4c430 100644
--- a/fs/cifs/fcntl.c
+++ b/fs/cifs/fcntl.c
@@ -35,9 +35,8 @@ static __u32 convert_to_cifs_notify_flags(unsigned long fcntl_notify_flags)
35 35
36 /* No way on Linux VFS to ask to monitor xattr 36 /* No way on Linux VFS to ask to monitor xattr
37 changes (and no stream support either */ 37 changes (and no stream support either */
38 if (fcntl_notify_flags & DN_ACCESS) { 38 if (fcntl_notify_flags & DN_ACCESS)
39 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_LAST_ACCESS; 39 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_LAST_ACCESS;
40 }
41 if (fcntl_notify_flags & DN_MODIFY) { 40 if (fcntl_notify_flags & DN_MODIFY) {
42 /* What does this mean on directories? */ 41 /* What does this mean on directories? */
43 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_LAST_WRITE | 42 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_LAST_WRITE |
@@ -47,9 +46,8 @@ static __u32 convert_to_cifs_notify_flags(unsigned long fcntl_notify_flags)
47 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_CREATION | 46 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_CREATION |
48 FILE_NOTIFY_CHANGE_LAST_WRITE; 47 FILE_NOTIFY_CHANGE_LAST_WRITE;
49 } 48 }
50 if (fcntl_notify_flags & DN_DELETE) { 49 if (fcntl_notify_flags & DN_DELETE)
51 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_LAST_WRITE; 50 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_LAST_WRITE;
52 }
53 if (fcntl_notify_flags & DN_RENAME) { 51 if (fcntl_notify_flags & DN_RENAME) {
54 /* BB review this - checking various server behaviors */ 52 /* BB review this - checking various server behaviors */
55 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_DIR_NAME | 53 cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_DIR_NAME |
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 5f7c374ae89c..fa849c91d323 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -353,9 +353,9 @@ static int cifs_reopen_file(struct file *file, int can_flush)
353 int disposition = FILE_OPEN; 353 int disposition = FILE_OPEN;
354 __u16 netfid; 354 __u16 netfid;
355 355
356 if (file->private_data) { 356 if (file->private_data)
357 pCifsFile = (struct cifsFileInfo *)file->private_data; 357 pCifsFile = (struct cifsFileInfo *)file->private_data;
358 } else 358 else
359 return -EBADF; 359 return -EBADF;
360 360
361 xid = GetXid(); 361 xid = GetXid();
@@ -499,9 +499,8 @@ int cifs_close(struct inode *inode, struct file *file)
499 the struct would be in each open file, 499 the struct would be in each open file,
500 but this should give enough time to 500 but this should give enough time to
501 clear the socket */ 501 clear the socket */
502#ifdef CONFIG_CIFS_DEBUG2 502 cFYI(DBG2,
503 cFYI(1, ("close delay, write pending")); 503 ("close delay, write pending"));
504#endif /* DEBUG2 */
505 msleep(timeout); 504 msleep(timeout);
506 timeout *= 4; 505 timeout *= 4;
507 } 506 }
@@ -1423,9 +1422,8 @@ static int cifs_writepage(struct page *page, struct writeback_control *wbc)
1423 xid = GetXid(); 1422 xid = GetXid();
1424/* BB add check for wbc flags */ 1423/* BB add check for wbc flags */
1425 page_cache_get(page); 1424 page_cache_get(page);
1426 if (!PageUptodate(page)) { 1425 if (!PageUptodate(page))
1427 cFYI(1, ("ppw - page not up to date")); 1426 cFYI(1, ("ppw - page not up to date"));
1428 }
1429 1427
1430 /* 1428 /*
1431 * Set the "writeback" flag, and clear "dirty" in the radix tree. 1429 * Set the "writeback" flag, and clear "dirty" in the radix tree.
@@ -1460,9 +1458,9 @@ static int cifs_commit_write(struct file *file, struct page *page,
1460 cFYI(1, ("commit write for page %p up to position %lld for %d", 1458 cFYI(1, ("commit write for page %p up to position %lld for %d",
1461 page, position, to)); 1459 page, position, to));
1462 spin_lock(&inode->i_lock); 1460 spin_lock(&inode->i_lock);
1463 if (position > inode->i_size) { 1461 if (position > inode->i_size)
1464 i_size_write(inode, position); 1462 i_size_write(inode, position);
1465 } 1463
1466 spin_unlock(&inode->i_lock); 1464 spin_unlock(&inode->i_lock);
1467 if (!PageUptodate(page)) { 1465 if (!PageUptodate(page)) {
1468 position = ((loff_t)page->index << PAGE_CACHE_SHIFT) + offset; 1466 position = ((loff_t)page->index << PAGE_CACHE_SHIFT) + offset;
@@ -1596,9 +1594,9 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
1596 } 1594 }
1597 open_file = (struct cifsFileInfo *)file->private_data; 1595 open_file = (struct cifsFileInfo *)file->private_data;
1598 1596
1599 if ((file->f_flags & O_ACCMODE) == O_WRONLY) { 1597 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
1600 cFYI(1, ("attempting read on write only file instance")); 1598 cFYI(1, ("attempting read on write only file instance"));
1601 } 1599
1602 for (total_read = 0, current_offset = read_data; 1600 for (total_read = 0, current_offset = read_data;
1603 read_size > total_read; 1601 read_size > total_read;
1604 total_read += bytes_read, current_offset += bytes_read) { 1602 total_read += bytes_read, current_offset += bytes_read) {
@@ -1625,9 +1623,8 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
1625 smb_read_data + 1623 smb_read_data +
1626 4 /* RFC1001 length field */ + 1624 4 /* RFC1001 length field */ +
1627 le16_to_cpu(pSMBr->DataOffset), 1625 le16_to_cpu(pSMBr->DataOffset),
1628 bytes_read)) { 1626 bytes_read))
1629 rc = -EFAULT; 1627 rc = -EFAULT;
1630 }
1631 1628
1632 if (buf_type == CIFS_SMALL_BUFFER) 1629 if (buf_type == CIFS_SMALL_BUFFER)
1633 cifs_small_buf_release(smb_read_data); 1630 cifs_small_buf_release(smb_read_data);
@@ -1814,9 +1811,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
1814 pTcon = cifs_sb->tcon; 1811 pTcon = cifs_sb->tcon;
1815 1812
1816 pagevec_init(&lru_pvec, 0); 1813 pagevec_init(&lru_pvec, 0);
1817#ifdef CONFIG_CIFS_DEBUG2 1814 cFYI(DBG2, ("rpages: num pages %d", num_pages));
1818 cFYI(1, ("rpages: num pages %d", num_pages));
1819#endif
1820 for (i = 0; i < num_pages; ) { 1815 for (i = 0; i < num_pages; ) {
1821 unsigned contig_pages; 1816 unsigned contig_pages;
1822 struct page *tmp_page; 1817 struct page *tmp_page;
@@ -1849,10 +1844,8 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
1849 /* Read size needs to be in multiples of one page */ 1844 /* Read size needs to be in multiples of one page */
1850 read_size = min_t(const unsigned int, read_size, 1845 read_size = min_t(const unsigned int, read_size,
1851 cifs_sb->rsize & PAGE_CACHE_MASK); 1846 cifs_sb->rsize & PAGE_CACHE_MASK);
1852#ifdef CONFIG_CIFS_DEBUG2 1847 cFYI(DBG2, ("rpages: read size 0x%x contiguous pages %d",
1853 cFYI(1, ("rpages: read size 0x%x contiguous pages %d",
1854 read_size, contig_pages)); 1848 read_size, contig_pages));
1855#endif
1856 rc = -EAGAIN; 1849 rc = -EAGAIN;
1857 while (rc == -EAGAIN) { 1850 while (rc == -EAGAIN) {
1858 if ((open_file->invalidHandle) && 1851 if ((open_file->invalidHandle) &&
@@ -2026,7 +2019,7 @@ int is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file)
2026 struct cifs_sb_info *cifs_sb; 2019 struct cifs_sb_info *cifs_sb;
2027 2020
2028 cifs_sb = CIFS_SB(cifsInode->vfs_inode.i_sb); 2021 cifs_sb = CIFS_SB(cifsInode->vfs_inode.i_sb);
2029 if ( cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO ) { 2022 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) {
2030 /* since no page cache to corrupt on directio 2023 /* since no page cache to corrupt on directio
2031 we can change size safely */ 2024 we can change size safely */
2032 return 1; 2025 return 1;
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index b1a4a65eaa08..24eb4d392155 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -29,6 +29,130 @@
29#include "cifs_debug.h" 29#include "cifs_debug.h"
30#include "cifs_fs_sb.h" 30#include "cifs_fs_sb.h"
31 31
32
33static void cifs_set_ops(struct inode *inode)
34{
35 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
36
37 switch (inode->i_mode & S_IFMT) {
38 case S_IFREG:
39 inode->i_op = &cifs_file_inode_ops;
40 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) {
41 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
42 inode->i_fop = &cifs_file_direct_nobrl_ops;
43 else
44 inode->i_fop = &cifs_file_direct_ops;
45 } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
46 inode->i_fop = &cifs_file_nobrl_ops;
47 else { /* not direct, send byte range locks */
48 inode->i_fop = &cifs_file_ops;
49 }
50
51
52 /* check if server can support readpages */
53 if (cifs_sb->tcon->ses->server->maxBuf <
54 PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)
55 inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
56 else
57 inode->i_data.a_ops = &cifs_addr_ops;
58 break;
59 case S_IFDIR:
60 inode->i_op = &cifs_dir_inode_ops;
61 inode->i_fop = &cifs_dir_ops;
62 break;
63 case S_IFLNK:
64 inode->i_op = &cifs_symlink_inode_ops;
65 break;
66 default:
67 init_special_inode(inode, inode->i_mode, inode->i_rdev);
68 break;
69 }
70}
71
72static void cifs_unix_info_to_inode(struct inode *inode,
73 FILE_UNIX_BASIC_INFO *info, int force_uid_gid)
74{
75 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
76 struct cifsInodeInfo *cifsInfo = CIFS_I(inode);
77 __u64 num_of_bytes = le64_to_cpu(info->NumOfBytes);
78 __u64 end_of_file = le64_to_cpu(info->EndOfFile);
79
80 inode->i_atime = cifs_NTtimeToUnix(le64_to_cpu(info->LastAccessTime));
81 inode->i_mtime =
82 cifs_NTtimeToUnix(le64_to_cpu(info->LastModificationTime));
83 inode->i_ctime = cifs_NTtimeToUnix(le64_to_cpu(info->LastStatusChange));
84 inode->i_mode = le64_to_cpu(info->Permissions);
85
86 /*
87 * Since we set the inode type below we need to mask off
88 * to avoid strange results if bits set above.
89 */
90 inode->i_mode &= ~S_IFMT;
91 switch (le32_to_cpu(info->Type)) {
92 case UNIX_FILE:
93 inode->i_mode |= S_IFREG;
94 break;
95 case UNIX_SYMLINK:
96 inode->i_mode |= S_IFLNK;
97 break;
98 case UNIX_DIR:
99 inode->i_mode |= S_IFDIR;
100 break;
101 case UNIX_CHARDEV:
102 inode->i_mode |= S_IFCHR;
103 inode->i_rdev = MKDEV(le64_to_cpu(info->DevMajor),
104 le64_to_cpu(info->DevMinor) & MINORMASK);
105 break;
106 case UNIX_BLOCKDEV:
107 inode->i_mode |= S_IFBLK;
108 inode->i_rdev = MKDEV(le64_to_cpu(info->DevMajor),
109 le64_to_cpu(info->DevMinor) & MINORMASK);
110 break;
111 case UNIX_FIFO:
112 inode->i_mode |= S_IFIFO;
113 break;
114 case UNIX_SOCKET:
115 inode->i_mode |= S_IFSOCK;
116 break;
117 default:
118 /* safest to call it a file if we do not know */
119 inode->i_mode |= S_IFREG;
120 cFYI(1, ("unknown type %d", le32_to_cpu(info->Type)));
121 break;
122 }
123
124 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) &&
125 !force_uid_gid)
126 inode->i_uid = cifs_sb->mnt_uid;
127 else
128 inode->i_uid = le64_to_cpu(info->Uid);
129
130 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) &&
131 !force_uid_gid)
132 inode->i_gid = cifs_sb->mnt_gid;
133 else
134 inode->i_gid = le64_to_cpu(info->Gid);
135
136 inode->i_nlink = le64_to_cpu(info->Nlinks);
137
138 spin_lock(&inode->i_lock);
139 if (is_size_safe_to_change(cifsInfo, end_of_file)) {
140 /*
141 * We can not safely change the file size here if the client
142 * is writing to it due to potential races.
143 */
144 i_size_write(inode, end_of_file);
145
146 /*
147 * i_blocks is not related to (i_size / i_blksize),
148 * but instead 512 byte (2**9) size is required for
149 * calculating num blocks.
150 */
151 inode->i_blocks = (512 - 1 + num_of_bytes) >> 9;
152 }
153 spin_unlock(&inode->i_lock);
154}
155
32int cifs_get_inode_info_unix(struct inode **pinode, 156int cifs_get_inode_info_unix(struct inode **pinode,
33 const unsigned char *search_path, struct super_block *sb, int xid) 157 const unsigned char *search_path, struct super_block *sb, int xid)
34{ 158{
@@ -74,7 +198,6 @@ int cifs_get_inode_info_unix(struct inode **pinode,
74 } 198 }
75 } else { 199 } else {
76 struct cifsInodeInfo *cifsInfo; 200 struct cifsInodeInfo *cifsInfo;
77 __u32 type = le32_to_cpu(findData.Type);
78 __u64 num_of_bytes = le64_to_cpu(findData.NumOfBytes); 201 __u64 num_of_bytes = le64_to_cpu(findData.NumOfBytes);
79 __u64 end_of_file = le64_to_cpu(findData.EndOfFile); 202 __u64 end_of_file = le64_to_cpu(findData.EndOfFile);
80 203
@@ -105,112 +228,16 @@ int cifs_get_inode_info_unix(struct inode **pinode,
105 /* this is ok to set on every inode revalidate */ 228 /* this is ok to set on every inode revalidate */
106 atomic_set(&cifsInfo->inUse, 1); 229 atomic_set(&cifsInfo->inUse, 1);
107 230
108 inode->i_atime = 231 cifs_unix_info_to_inode(inode, &findData, 0);
109 cifs_NTtimeToUnix(le64_to_cpu(findData.LastAccessTime));
110 inode->i_mtime =
111 cifs_NTtimeToUnix(le64_to_cpu
112 (findData.LastModificationTime));
113 inode->i_ctime =
114 cifs_NTtimeToUnix(le64_to_cpu(findData.LastStatusChange));
115 inode->i_mode = le64_to_cpu(findData.Permissions);
116 /* since we set the inode type below we need to mask off
117 to avoid strange results if bits set above */
118 inode->i_mode &= ~S_IFMT;
119 if (type == UNIX_FILE) {
120 inode->i_mode |= S_IFREG;
121 } else if (type == UNIX_SYMLINK) {
122 inode->i_mode |= S_IFLNK;
123 } else if (type == UNIX_DIR) {
124 inode->i_mode |= S_IFDIR;
125 } else if (type == UNIX_CHARDEV) {
126 inode->i_mode |= S_IFCHR;
127 inode->i_rdev = MKDEV(le64_to_cpu(findData.DevMajor),
128 le64_to_cpu(findData.DevMinor) & MINORMASK);
129 } else if (type == UNIX_BLOCKDEV) {
130 inode->i_mode |= S_IFBLK;
131 inode->i_rdev = MKDEV(le64_to_cpu(findData.DevMajor),
132 le64_to_cpu(findData.DevMinor) & MINORMASK);
133 } else if (type == UNIX_FIFO) {
134 inode->i_mode |= S_IFIFO;
135 } else if (type == UNIX_SOCKET) {
136 inode->i_mode |= S_IFSOCK;
137 } else {
138 /* safest to call it a file if we do not know */
139 inode->i_mode |= S_IFREG;
140 cFYI(1, ("unknown type %d", type));
141 }
142 232
143 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)
144 inode->i_uid = cifs_sb->mnt_uid;
145 else
146 inode->i_uid = le64_to_cpu(findData.Uid);
147
148 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID)
149 inode->i_gid = cifs_sb->mnt_gid;
150 else
151 inode->i_gid = le64_to_cpu(findData.Gid);
152
153 inode->i_nlink = le64_to_cpu(findData.Nlinks);
154
155 spin_lock(&inode->i_lock);
156 if (is_size_safe_to_change(cifsInfo, end_of_file)) {
157 /* can not safely change the file size here if the
158 client is writing to it due to potential races */
159 i_size_write(inode, end_of_file);
160
161 /* blksize needs to be multiple of two. So safer to default to
162 blksize and blkbits set in superblock so 2**blkbits and blksize
163 will match rather than setting to:
164 (pTcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & 0xFFFFFE00;*/
165
166 /* This seems incredibly stupid but it turns out that i_blocks
167 is not related to (i_size / i_blksize), instead 512 byte size
168 is required for calculating num blocks */
169
170 /* 512 bytes (2**9) is the fake blocksize that must be used */
171 /* for this calculation */
172 inode->i_blocks = (512 - 1 + num_of_bytes) >> 9;
173 }
174 spin_unlock(&inode->i_lock);
175 233
176 if (num_of_bytes < end_of_file) 234 if (num_of_bytes < end_of_file)
177 cFYI(1, ("allocation size less than end of file")); 235 cFYI(1, ("allocation size less than end of file"));
178 cFYI(1, ("Size %ld and blocks %llu", 236 cFYI(1, ("Size %ld and blocks %llu",
179 (unsigned long) inode->i_size, 237 (unsigned long) inode->i_size,
180 (unsigned long long)inode->i_blocks)); 238 (unsigned long long)inode->i_blocks));
181 if (S_ISREG(inode->i_mode)) { 239
182 cFYI(1, ("File inode")); 240 cifs_set_ops(inode);
183 inode->i_op = &cifs_file_inode_ops;
184 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) {
185 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
186 inode->i_fop =
187 &cifs_file_direct_nobrl_ops;
188 else
189 inode->i_fop = &cifs_file_direct_ops;
190 } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
191 inode->i_fop = &cifs_file_nobrl_ops;
192 else /* not direct, send byte range locks */
193 inode->i_fop = &cifs_file_ops;
194
195 /* check if server can support readpages */
196 if (pTcon->ses->server->maxBuf <
197 PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)
198 inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
199 else
200 inode->i_data.a_ops = &cifs_addr_ops;
201 } else if (S_ISDIR(inode->i_mode)) {
202 cFYI(1, ("Directory inode"));
203 inode->i_op = &cifs_dir_inode_ops;
204 inode->i_fop = &cifs_dir_ops;
205 } else if (S_ISLNK(inode->i_mode)) {
206 cFYI(1, ("Symbolic Link inode"));
207 inode->i_op = &cifs_symlink_inode_ops;
208 /* tmp_inode->i_fop = */ /* do not need to set to anything */
209 } else {
210 cFYI(1, ("Init special inode"));
211 init_special_inode(inode, inode->i_mode,
212 inode->i_rdev);
213 }
214 } 241 }
215 return rc; 242 return rc;
216} 243}
@@ -490,9 +517,9 @@ int cifs_get_inode_info(struct inode **pinode,
490 if (decode_sfu_inode(inode, 517 if (decode_sfu_inode(inode,
491 le64_to_cpu(pfindData->EndOfFile), 518 le64_to_cpu(pfindData->EndOfFile),
492 search_path, 519 search_path,
493 cifs_sb, xid)) { 520 cifs_sb, xid))
494 cFYI(1, ("Unrecognized sfu inode type")); 521 cFYI(1, ("Unrecognized sfu inode type"));
495 } 522
496 cFYI(1, ("sfu mode 0%o", inode->i_mode)); 523 cFYI(1, ("sfu mode 0%o", inode->i_mode));
497 } else { 524 } else {
498 inode->i_mode |= S_IFREG; 525 inode->i_mode |= S_IFREG;
@@ -546,36 +573,7 @@ int cifs_get_inode_info(struct inode **pinode,
546 atomic_set(&cifsInfo->inUse, 1); 573 atomic_set(&cifsInfo->inUse, 1);
547 } 574 }
548 575
549 if (S_ISREG(inode->i_mode)) { 576 cifs_set_ops(inode);
550 cFYI(1, ("File inode"));
551 inode->i_op = &cifs_file_inode_ops;
552 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) {
553 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
554 inode->i_fop =
555 &cifs_file_direct_nobrl_ops;
556 else
557 inode->i_fop = &cifs_file_direct_ops;
558 } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
559 inode->i_fop = &cifs_file_nobrl_ops;
560 else /* not direct, send byte range locks */
561 inode->i_fop = &cifs_file_ops;
562
563 if (pTcon->ses->server->maxBuf <
564 PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)
565 inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
566 else
567 inode->i_data.a_ops = &cifs_addr_ops;
568 } else if (S_ISDIR(inode->i_mode)) {
569 cFYI(1, ("Directory inode"));
570 inode->i_op = &cifs_dir_inode_ops;
571 inode->i_fop = &cifs_dir_ops;
572 } else if (S_ISLNK(inode->i_mode)) {
573 cFYI(1, ("Symbolic Link inode"));
574 inode->i_op = &cifs_symlink_inode_ops;
575 } else {
576 init_special_inode(inode, inode->i_mode,
577 inode->i_rdev);
578 }
579 } 577 }
580 kfree(buf); 578 kfree(buf);
581 return rc; 579 return rc;
@@ -792,17 +790,12 @@ psx_del_no_retry:
792} 790}
793 791
794static void posix_fill_in_inode(struct inode *tmp_inode, 792static void posix_fill_in_inode(struct inode *tmp_inode,
795 FILE_UNIX_BASIC_INFO *pData, int *pobject_type, int isNewInode) 793 FILE_UNIX_BASIC_INFO *pData, int isNewInode)
796{ 794{
795 struct cifsInodeInfo *cifsInfo = CIFS_I(tmp_inode);
797 loff_t local_size; 796 loff_t local_size;
798 struct timespec local_mtime; 797 struct timespec local_mtime;
799 798
800 struct cifsInodeInfo *cifsInfo = CIFS_I(tmp_inode);
801 struct cifs_sb_info *cifs_sb = CIFS_SB(tmp_inode->i_sb);
802
803 __u32 type = le32_to_cpu(pData->Type);
804 __u64 num_of_bytes = le64_to_cpu(pData->NumOfBytes);
805 __u64 end_of_file = le64_to_cpu(pData->EndOfFile);
806 cifsInfo->time = jiffies; 799 cifsInfo->time = jiffies;
807 atomic_inc(&cifsInfo->inUse); 800 atomic_inc(&cifsInfo->inUse);
808 801
@@ -810,115 +803,27 @@ static void posix_fill_in_inode(struct inode *tmp_inode,
810 local_mtime = tmp_inode->i_mtime; 803 local_mtime = tmp_inode->i_mtime;
811 local_size = tmp_inode->i_size; 804 local_size = tmp_inode->i_size;
812 805
813 tmp_inode->i_atime = 806 cifs_unix_info_to_inode(tmp_inode, pData, 1);
814 cifs_NTtimeToUnix(le64_to_cpu(pData->LastAccessTime)); 807 cifs_set_ops(tmp_inode);
815 tmp_inode->i_mtime =
816 cifs_NTtimeToUnix(le64_to_cpu(pData->LastModificationTime));
817 tmp_inode->i_ctime =
818 cifs_NTtimeToUnix(le64_to_cpu(pData->LastStatusChange));
819
820 tmp_inode->i_mode = le64_to_cpu(pData->Permissions);
821 /* since we set the inode type below we need to mask off type
822 to avoid strange results if bits above were corrupt */
823 tmp_inode->i_mode &= ~S_IFMT;
824 if (type == UNIX_FILE) {
825 *pobject_type = DT_REG;
826 tmp_inode->i_mode |= S_IFREG;
827 } else if (type == UNIX_SYMLINK) {
828 *pobject_type = DT_LNK;
829 tmp_inode->i_mode |= S_IFLNK;
830 } else if (type == UNIX_DIR) {
831 *pobject_type = DT_DIR;
832 tmp_inode->i_mode |= S_IFDIR;
833 } else if (type == UNIX_CHARDEV) {
834 *pobject_type = DT_CHR;
835 tmp_inode->i_mode |= S_IFCHR;
836 tmp_inode->i_rdev = MKDEV(le64_to_cpu(pData->DevMajor),
837 le64_to_cpu(pData->DevMinor) & MINORMASK);
838 } else if (type == UNIX_BLOCKDEV) {
839 *pobject_type = DT_BLK;
840 tmp_inode->i_mode |= S_IFBLK;
841 tmp_inode->i_rdev = MKDEV(le64_to_cpu(pData->DevMajor),
842 le64_to_cpu(pData->DevMinor) & MINORMASK);
843 } else if (type == UNIX_FIFO) {
844 *pobject_type = DT_FIFO;
845 tmp_inode->i_mode |= S_IFIFO;
846 } else if (type == UNIX_SOCKET) {
847 *pobject_type = DT_SOCK;
848 tmp_inode->i_mode |= S_IFSOCK;
849 } else {
850 /* safest to just call it a file */
851 *pobject_type = DT_REG;
852 tmp_inode->i_mode |= S_IFREG;
853 cFYI(1, ("unknown inode type %d", type));
854 }
855
856#ifdef CONFIG_CIFS_DEBUG2
857 cFYI(1, ("object type: %d", type));
858#endif
859 tmp_inode->i_uid = le64_to_cpu(pData->Uid);
860 tmp_inode->i_gid = le64_to_cpu(pData->Gid);
861 tmp_inode->i_nlink = le64_to_cpu(pData->Nlinks);
862
863 spin_lock(&tmp_inode->i_lock);
864 if (is_size_safe_to_change(cifsInfo, end_of_file)) {
865 /* can not safely change the file size here if the
866 client is writing to it due to potential races */
867 i_size_write(tmp_inode, end_of_file);
868 808
869 /* 512 bytes (2**9) is the fake blocksize that must be used */ 809 if (!S_ISREG(tmp_inode->i_mode))
870 /* for this calculation, not the real blocksize */ 810 return;
871 tmp_inode->i_blocks = (512 - 1 + num_of_bytes) >> 9;
872 }
873 spin_unlock(&tmp_inode->i_lock);
874
875 if (S_ISREG(tmp_inode->i_mode)) {
876 cFYI(1, ("File inode"));
877 tmp_inode->i_op = &cifs_file_inode_ops;
878
879 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) {
880 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
881 tmp_inode->i_fop = &cifs_file_direct_nobrl_ops;
882 else
883 tmp_inode->i_fop = &cifs_file_direct_ops;
884 811
885 } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) 812 /*
886 tmp_inode->i_fop = &cifs_file_nobrl_ops; 813 * No sense invalidating pages for new inode
887 else 814 * since we we have not started caching
888 tmp_inode->i_fop = &cifs_file_ops; 815 * readahead file data yet.
889 816 */
890 if ((cifs_sb->tcon) && (cifs_sb->tcon->ses) && 817 if (isNewInode)
891 (cifs_sb->tcon->ses->server->maxBuf < 818 return;
892 PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE))
893 tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
894 else
895 tmp_inode->i_data.a_ops = &cifs_addr_ops;
896
897 if (isNewInode)
898 return; /* No sense invalidating pages for new inode
899 since we we have not started caching
900 readahead file data yet */
901 819
902 if (timespec_equal(&tmp_inode->i_mtime, &local_mtime) && 820 if (timespec_equal(&tmp_inode->i_mtime, &local_mtime) &&
903 (local_size == tmp_inode->i_size)) { 821 (local_size == tmp_inode->i_size)) {
904 cFYI(1, ("inode exists but unchanged")); 822 cFYI(1, ("inode exists but unchanged"));
905 } else {
906 /* file may have changed on server */
907 cFYI(1, ("invalidate inode, readdir detected change"));
908 invalidate_remote_inode(tmp_inode);
909 }
910 } else if (S_ISDIR(tmp_inode->i_mode)) {
911 cFYI(1, ("Directory inode"));
912 tmp_inode->i_op = &cifs_dir_inode_ops;
913 tmp_inode->i_fop = &cifs_dir_ops;
914 } else if (S_ISLNK(tmp_inode->i_mode)) {
915 cFYI(1, ("Symbolic Link inode"));
916 tmp_inode->i_op = &cifs_symlink_inode_ops;
917/* tmp_inode->i_fop = *//* do not need to set to anything */
918 } else { 823 } else {
919 cFYI(1, ("Special inode")); 824 /* file may have changed on server */
920 init_special_inode(tmp_inode, tmp_inode->i_mode, 825 cFYI(1, ("invalidate inode, readdir detected change"));
921 tmp_inode->i_rdev); 826 invalidate_remote_inode(tmp_inode);
922 } 827 }
923} 828}
924 829
@@ -968,7 +873,6 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
968 cFYI(1, ("posix mkdir returned 0x%x", rc)); 873 cFYI(1, ("posix mkdir returned 0x%x", rc));
969 d_drop(direntry); 874 d_drop(direntry);
970 } else { 875 } else {
971 int obj_type;
972 if (pInfo->Type == cpu_to_le32(-1)) { 876 if (pInfo->Type == cpu_to_le32(-1)) {
973 /* no return info, go query for it */ 877 /* no return info, go query for it */
974 kfree(pInfo); 878 kfree(pInfo);
@@ -1004,7 +908,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
1004 /* we already checked in POSIXCreate whether 908 /* we already checked in POSIXCreate whether
1005 frame was long enough */ 909 frame was long enough */
1006 posix_fill_in_inode(direntry->d_inode, 910 posix_fill_in_inode(direntry->d_inode,
1007 pInfo, &obj_type, 1 /* NewInode */); 911 pInfo, 1 /* NewInode */);
1008#ifdef CONFIG_CIFS_DEBUG2 912#ifdef CONFIG_CIFS_DEBUG2
1009 cFYI(1, ("instantiated dentry %p %s to inode %p", 913 cFYI(1, ("instantiated dentry %p %s to inode %p",
1010 direntry, direntry->d_name.name, newinode)); 914 direntry, direntry->d_name.name, newinode));
@@ -1214,9 +1118,8 @@ int cifs_rename(struct inode *source_inode, struct dentry *source_direntry,
1214 } /* if we can not get memory just leave rc as EEXIST */ 1118 } /* if we can not get memory just leave rc as EEXIST */
1215 } 1119 }
1216 1120
1217 if (rc) { 1121 if (rc)
1218 cFYI(1, ("rename rc %d", rc)); 1122 cFYI(1, ("rename rc %d", rc));
1219 }
1220 1123
1221 if ((rc == -EIO) || (rc == -EEXIST)) { 1124 if ((rc == -EIO) || (rc == -EEXIST)) {
1222 int oplock = FALSE; 1125 int oplock = FALSE;
diff --git a/fs/cifs/ioctl.c b/fs/cifs/ioctl.c
index d24fe6880a04..5c792df13d62 100644
--- a/fs/cifs/ioctl.c
+++ b/fs/cifs/ioctl.c
@@ -30,7 +30,7 @@
30 30
31#define CIFS_IOC_CHECKUMOUNT _IO(0xCF, 2) 31#define CIFS_IOC_CHECKUMOUNT _IO(0xCF, 2)
32 32
33int cifs_ioctl (struct inode *inode, struct file *filep, 33int cifs_ioctl(struct inode *inode, struct file *filep,
34 unsigned int command, unsigned long arg) 34 unsigned int command, unsigned long arg)
35{ 35{
36 int rc = -ENOTTY; /* strange error - but the precedent */ 36 int rc = -ENOTTY; /* strange error - but the precedent */
diff --git a/fs/cifs/md4.c b/fs/cifs/md4.c
index a2415c1a14db..a725c2609d67 100644
--- a/fs/cifs/md4.c
+++ b/fs/cifs/md4.c
@@ -56,7 +56,7 @@ lshift(__u32 x, int s)
56 56
57/* this applies md4 to 64 byte chunks */ 57/* this applies md4 to 64 byte chunks */
58static void 58static void
59mdfour64(__u32 * M, __u32 * A, __u32 *B, __u32 * C, __u32 *D) 59mdfour64(__u32 *M, __u32 *A, __u32 *B, __u32 *C, __u32 *D)
60{ 60{
61 int j; 61 int j;
62 __u32 AA, BB, CC, DD; 62 __u32 AA, BB, CC, DD;
@@ -137,7 +137,7 @@ mdfour64(__u32 * M, __u32 * A, __u32 *B, __u32 * C, __u32 *D)
137} 137}
138 138
139static void 139static void
140copy64(__u32 * M, unsigned char *in) 140copy64(__u32 *M, unsigned char *in)
141{ 141{
142 int i; 142 int i;
143 143
diff --git a/fs/cifs/md5.c b/fs/cifs/md5.c
index f13f96d42fcf..462bbfefd4b6 100644
--- a/fs/cifs/md5.c
+++ b/fs/cifs/md5.c
@@ -161,7 +161,7 @@ MD5Final(unsigned char digest[16], struct MD5Context *ctx)
161 161
162/* This is the central step in the MD5 algorithm. */ 162/* This is the central step in the MD5 algorithm. */
163#define MD5STEP(f, w, x, y, z, data, s) \ 163#define MD5STEP(f, w, x, y, z, data, s) \
164 ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x ) 164 (w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x)
165 165
166/* 166/*
167 * The core of the MD5 algorithm, this alters an existing MD5 hash to 167 * The core of the MD5 algorithm, this alters an existing MD5 hash to
@@ -302,9 +302,8 @@ hmac_md5_init_limK_to_64(const unsigned char *key, int key_len,
302 int i; 302 int i;
303 303
304 /* if key is longer than 64 bytes truncate it */ 304 /* if key is longer than 64 bytes truncate it */
305 if (key_len > 64) { 305 if (key_len > 64)
306 key_len = 64; 306 key_len = 64;
307 }
308 307
309 /* start out by storing key in pads */ 308 /* start out by storing key in pads */
310 memset(ctx->k_ipad, 0, sizeof(ctx->k_ipad)); 309 memset(ctx->k_ipad, 0, sizeof(ctx->k_ipad));
@@ -359,9 +358,9 @@ hmac_md5(unsigned char key[16], unsigned char *data, int data_len,
359{ 358{
360 struct HMACMD5Context ctx; 359 struct HMACMD5Context ctx;
361 hmac_md5_init_limK_to_64(key, 16, &ctx); 360 hmac_md5_init_limK_to_64(key, 16, &ctx);
362 if (data_len != 0) { 361 if (data_len != 0)
363 hmac_md5_update(data, data_len, &ctx); 362 hmac_md5_update(data, data_len, &ctx);
364 } 363
365 hmac_md5_final(digest, &ctx); 364 hmac_md5_final(digest, &ctx);
366} 365}
367#endif 366#endif
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index 15546c2354c5..2a42d9fedbb2 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * fs/cifs/misc.c 2 * fs/cifs/misc.c
3 * 3 *
4 * Copyright (C) International Business Machines Corp., 2002,2007 4 * Copyright (C) International Business Machines Corp., 2002,2008
5 * Author(s): Steve French (sfrench@us.ibm.com) 5 * Author(s): Steve French (sfrench@us.ibm.com)
6 * 6 *
7 * This library is free software; you can redistribute it and/or modify 7 * This library is free software; you can redistribute it and/or modify
@@ -320,9 +320,9 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
320 if (treeCon->ses) { 320 if (treeCon->ses) {
321 if (treeCon->ses->capabilities & CAP_UNICODE) 321 if (treeCon->ses->capabilities & CAP_UNICODE)
322 buffer->Flags2 |= SMBFLG2_UNICODE; 322 buffer->Flags2 |= SMBFLG2_UNICODE;
323 if (treeCon->ses->capabilities & CAP_STATUS32) { 323 if (treeCon->ses->capabilities & CAP_STATUS32)
324 buffer->Flags2 |= SMBFLG2_ERR_STATUS; 324 buffer->Flags2 |= SMBFLG2_ERR_STATUS;
325 } 325
326 /* Uid is not converted */ 326 /* Uid is not converted */
327 buffer->Uid = treeCon->ses->Suid; 327 buffer->Uid = treeCon->ses->Suid;
328 buffer->Mid = GetNextMid(treeCon->ses->server); 328 buffer->Mid = GetNextMid(treeCon->ses->server);
@@ -610,7 +610,8 @@ dump_smb(struct smb_hdr *smb_buf, int smb_buf_length)
610 610
611 buffer = (unsigned char *) smb_buf; 611 buffer = (unsigned char *) smb_buf;
612 for (i = 0, j = 0; i < smb_buf_length; i++, j++) { 612 for (i = 0, j = 0; i < smb_buf_length; i++, j++) {
613 if (i % 8 == 0) { /* have reached the beginning of line */ 613 if (i % 8 == 0) {
614 /* have reached the beginning of line */
614 printk(KERN_DEBUG "| "); 615 printk(KERN_DEBUG "| ");
615 j = 0; 616 j = 0;
616 } 617 }
@@ -621,7 +622,8 @@ dump_smb(struct smb_hdr *smb_buf, int smb_buf_length)
621 else 622 else
622 debug_line[1 + (2 * j)] = '_'; 623 debug_line[1 + (2 * j)] = '_';
623 624
624 if (i % 8 == 7) { /* reached end of line, time to print ascii */ 625 if (i % 8 == 7) {
626 /* reached end of line, time to print ascii */
625 debug_line[16] = 0; 627 debug_line[16] = 0;
626 printk(" | %s\n", debug_line); 628 printk(" | %s\n", debug_line);
627 } 629 }
@@ -631,7 +633,7 @@ dump_smb(struct smb_hdr *smb_buf, int smb_buf_length)
631 debug_line[2 * j] = ' '; 633 debug_line[2 * j] = ' ';
632 debug_line[1 + (2 * j)] = ' '; 634 debug_line[1 + (2 * j)] = ' ';
633 } 635 }
634 printk( " | %s\n", debug_line); 636 printk(" | %s\n", debug_line);
635 return; 637 return;
636} 638}
637 639
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
index 646e1f06941b..3b5a5ce882b6 100644
--- a/fs/cifs/netmisc.c
+++ b/fs/cifs/netmisc.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * fs/cifs/netmisc.c 2 * fs/cifs/netmisc.c
3 * 3 *
4 * Copyright (c) International Business Machines Corp., 2002 4 * Copyright (c) International Business Machines Corp., 2002,2008
5 * Author(s): Steve French (sfrench@us.ibm.com) 5 * Author(s): Steve French (sfrench@us.ibm.com)
6 * 6 *
7 * Error mapping routines from Samba libsmb/errormap.c 7 * Error mapping routines from Samba libsmb/errormap.c
@@ -150,9 +150,7 @@ static int canonicalize_unc(char *cp)
150 if (cp[i] == '\\') 150 if (cp[i] == '\\')
151 break; 151 break;
152 if (cp[i] == '/') { 152 if (cp[i] == '/') {
153#ifdef CONFIG_CIFS_DEBUG2 153 cFYI(DBG2, ("change slash to \\ in malformed UNC"));
154 cFYI(1, ("change slash to backslash in malformed UNC"));
155#endif
156 cp[i] = '\\'; 154 cp[i] = '\\';
157 return 1; 155 return 1;
158 } 156 }
@@ -178,9 +176,7 @@ cifs_inet_pton(int address_family, char *cp, void *dst)
178 } else if (address_family == AF_INET6) { 176 } else if (address_family == AF_INET6) {
179 ret = in6_pton(cp, -1 /* len */, dst , '\\', NULL); 177 ret = in6_pton(cp, -1 /* len */, dst , '\\', NULL);
180 } 178 }
181#ifdef CONFIG_CIFS_DEBUG2 179 cFYI(DBG2, ("address conversion returned %d for %s", ret, cp));
182 cFYI(1, ("address conversion returned %d for %s", ret, cp));
183#endif
184 if (ret > 0) 180 if (ret > 0)
185 ret = 1; 181 ret = 1;
186 return ret; 182 return ret;
@@ -253,7 +249,8 @@ static const struct {
253 ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_MIX}, { 249 ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_MIX}, {
254 ERRHRD, ERRgeneral, NT_STATUS_INVALID_QUOTA_LOWER}, { 250 ERRHRD, ERRgeneral, NT_STATUS_INVALID_QUOTA_LOWER}, {
255 ERRHRD, ERRgeneral, NT_STATUS_DISK_CORRUPT_ERROR}, { 251 ERRHRD, ERRgeneral, NT_STATUS_DISK_CORRUPT_ERROR}, {
256 ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_INVALID}, { /* mapping changed since shell does lookup on * and expects file not found */ 252 /* mapping changed since shell does lookup on * expects FileNotFound */
253 ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_INVALID}, {
257 ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_NOT_FOUND}, { 254 ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_NOT_FOUND}, {
258 ERRDOS, ERRalreadyexists, NT_STATUS_OBJECT_NAME_COLLISION}, { 255 ERRDOS, ERRalreadyexists, NT_STATUS_OBJECT_NAME_COLLISION}, {
259 ERRHRD, ERRgeneral, NT_STATUS_HANDLE_NOT_WAITABLE}, { 256 ERRHRD, ERRgeneral, NT_STATUS_HANDLE_NOT_WAITABLE}, {
@@ -820,7 +817,8 @@ map_smb_to_linux_error(struct smb_hdr *smb, int logErr)
820 /* old style errors */ 817 /* old style errors */
821 818
822 /* DOS class smb error codes - map DOS */ 819 /* DOS class smb error codes - map DOS */
823 if (smberrclass == ERRDOS) { /* 1 byte field no need to byte reverse */ 820 if (smberrclass == ERRDOS) {
821 /* 1 byte field no need to byte reverse */
824 for (i = 0; 822 for (i = 0;
825 i < 823 i <
826 sizeof(mapping_table_ERRDOS) / 824 sizeof(mapping_table_ERRDOS) /
@@ -834,7 +832,8 @@ map_smb_to_linux_error(struct smb_hdr *smb, int logErr)
834 } 832 }
835 /* else try next error mapping one to see if match */ 833 /* else try next error mapping one to see if match */
836 } 834 }
837 } else if (smberrclass == ERRSRV) { /* server class of error codes */ 835 } else if (smberrclass == ERRSRV) {
836 /* server class of error codes */
838 for (i = 0; 837 for (i = 0;
839 i < 838 i <
840 sizeof(mapping_table_ERRSRV) / 839 sizeof(mapping_table_ERRSRV) /
@@ -922,8 +921,8 @@ struct timespec cnvrtDosUnixTm(__u16 date, __u16 time)
922{ 921{
923 struct timespec ts; 922 struct timespec ts;
924 int sec, min, days, month, year; 923 int sec, min, days, month, year;
925 SMB_TIME * st = (SMB_TIME *)&time; 924 SMB_TIME *st = (SMB_TIME *)&time;
926 SMB_DATE * sd = (SMB_DATE *)&date; 925 SMB_DATE *sd = (SMB_DATE *)&date;
927 926
928 cFYI(1, ("date %d time %d", date, time)); 927 cFYI(1, ("date %d time %d", date, time));
929 928
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 0f22def4bdff..32b445edc882 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Directory search handling 4 * Directory search handling
5 * 5 *
6 * Copyright (C) International Business Machines Corp., 2004, 2007 6 * Copyright (C) International Business Machines Corp., 2004, 2008
7 * Author(s): Steve French (sfrench@us.ibm.com) 7 * Author(s): Steve French (sfrench@us.ibm.com)
8 * 8 *
9 * This library is free software; you can redistribute it and/or modify 9 * This library is free software; you can redistribute it and/or modify
@@ -42,17 +42,18 @@ static void dump_cifs_file_struct(struct file *file, char *label)
42 cFYI(1, ("empty cifs private file data")); 42 cFYI(1, ("empty cifs private file data"));
43 return; 43 return;
44 } 44 }
45 if (cf->invalidHandle) { 45 if (cf->invalidHandle)
46 cFYI(1, ("invalid handle")); 46 cFYI(1, ("invalid handle"));
47 } 47 if (cf->srch_inf.endOfSearch)
48 if (cf->srch_inf.endOfSearch) {
49 cFYI(1, ("end of search")); 48 cFYI(1, ("end of search"));
50 } 49 if (cf->srch_inf.emptyDir)
51 if (cf->srch_inf.emptyDir) {
52 cFYI(1, ("empty dir")); 50 cFYI(1, ("empty dir"));
53 }
54 } 51 }
55} 52}
53#else
54static inline void dump_cifs_file_struct(struct file *file, char *label)
55{
56}
56#endif /* DEBUG2 */ 57#endif /* DEBUG2 */
57 58
58/* Returns one if new inode created (which therefore needs to be hashed) */ 59/* Returns one if new inode created (which therefore needs to be hashed) */
@@ -150,7 +151,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
150 cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime)); 151 cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime));
151 } else { /* legacy, OS2 and DOS style */ 152 } else { /* legacy, OS2 and DOS style */
152/* struct timespec ts;*/ 153/* struct timespec ts;*/
153 FIND_FILE_STANDARD_INFO * pfindData = 154 FIND_FILE_STANDARD_INFO *pfindData =
154 (FIND_FILE_STANDARD_INFO *)buf; 155 (FIND_FILE_STANDARD_INFO *)buf;
155 156
156 tmp_inode->i_mtime = cnvrtDosUnixTm( 157 tmp_inode->i_mtime = cnvrtDosUnixTm(
@@ -198,9 +199,8 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
198 if (attr & ATTR_DIRECTORY) { 199 if (attr & ATTR_DIRECTORY) {
199 *pobject_type = DT_DIR; 200 *pobject_type = DT_DIR;
200 /* override default perms since we do not lock dirs */ 201 /* override default perms since we do not lock dirs */
201 if (atomic_read(&cifsInfo->inUse) == 0) { 202 if (atomic_read(&cifsInfo->inUse) == 0)
202 tmp_inode->i_mode = cifs_sb->mnt_dir_mode; 203 tmp_inode->i_mode = cifs_sb->mnt_dir_mode;
203 }
204 tmp_inode->i_mode |= S_IFDIR; 204 tmp_inode->i_mode |= S_IFDIR;
205 } else if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) && 205 } else if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) &&
206 (attr & ATTR_SYSTEM)) { 206 (attr & ATTR_SYSTEM)) {
@@ -231,9 +231,8 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
231 } /* could add code here - to validate if device or weird share type? */ 231 } /* could add code here - to validate if device or weird share type? */
232 232
233 /* can not fill in nlink here as in qpathinfo version and Unx search */ 233 /* can not fill in nlink here as in qpathinfo version and Unx search */
234 if (atomic_read(&cifsInfo->inUse) == 0) { 234 if (atomic_read(&cifsInfo->inUse) == 0)
235 atomic_set(&cifsInfo->inUse, 1); 235 atomic_set(&cifsInfo->inUse, 1);
236 }
237 236
238 spin_lock(&tmp_inode->i_lock); 237 spin_lock(&tmp_inode->i_lock);
239 if (is_size_safe_to_change(cifsInfo, end_of_file)) { 238 if (is_size_safe_to_change(cifsInfo, end_of_file)) {
@@ -461,9 +460,8 @@ static int initiate_cifs_search(const int xid, struct file *file)
461 460
462 full_path = build_path_from_dentry(file->f_path.dentry); 461 full_path = build_path_from_dentry(file->f_path.dentry);
463 462
464 if (full_path == NULL) { 463 if (full_path == NULL)
465 return -ENOMEM; 464 return -ENOMEM;
466 }
467 465
468 cFYI(1, ("Full path: %s start at: %lld", full_path, file->f_pos)); 466 cFYI(1, ("Full path: %s start at: %lld", full_path, file->f_pos));
469 467
@@ -471,9 +469,9 @@ ffirst_retry:
471 /* test for Unix extensions */ 469 /* test for Unix extensions */
472 /* but now check for them on the share/mount not on the SMB session */ 470 /* but now check for them on the share/mount not on the SMB session */
473/* if (pTcon->ses->capabilities & CAP_UNIX) { */ 471/* if (pTcon->ses->capabilities & CAP_UNIX) { */
474 if (pTcon->unix_ext) { 472 if (pTcon->unix_ext)
475 cifsFile->srch_inf.info_level = SMB_FIND_FILE_UNIX; 473 cifsFile->srch_inf.info_level = SMB_FIND_FILE_UNIX;
476 } else if ((pTcon->ses->capabilities & 474 else if ((pTcon->ses->capabilities &
477 (CAP_NT_SMBS | CAP_NT_FIND)) == 0) { 475 (CAP_NT_SMBS | CAP_NT_FIND)) == 0) {
478 cifsFile->srch_inf.info_level = SMB_FIND_FILE_INFO_STANDARD; 476 cifsFile->srch_inf.info_level = SMB_FIND_FILE_INFO_STANDARD;
479 } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) { 477 } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
@@ -514,10 +512,10 @@ static int cifs_unicode_bytelen(char *str)
514static char *nxt_dir_entry(char *old_entry, char *end_of_smb, int level) 512static char *nxt_dir_entry(char *old_entry, char *end_of_smb, int level)
515{ 513{
516 char *new_entry; 514 char *new_entry;
517 FILE_DIRECTORY_INFO * pDirInfo = (FILE_DIRECTORY_INFO *)old_entry; 515 FILE_DIRECTORY_INFO *pDirInfo = (FILE_DIRECTORY_INFO *)old_entry;
518 516
519 if (level == SMB_FIND_FILE_INFO_STANDARD) { 517 if (level == SMB_FIND_FILE_INFO_STANDARD) {
520 FIND_FILE_STANDARD_INFO * pfData; 518 FIND_FILE_STANDARD_INFO *pfData;
521 pfData = (FIND_FILE_STANDARD_INFO *)pDirInfo; 519 pfData = (FIND_FILE_STANDARD_INFO *)pDirInfo;
522 520
523 new_entry = old_entry + sizeof(FIND_FILE_STANDARD_INFO) + 521 new_entry = old_entry + sizeof(FIND_FILE_STANDARD_INFO) +
@@ -553,7 +551,7 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
553 int len = 0; 551 int len = 0;
554 552
555 if (cfile->srch_inf.info_level == SMB_FIND_FILE_UNIX) { 553 if (cfile->srch_inf.info_level == SMB_FIND_FILE_UNIX) {
556 FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry; 554 FILE_UNIX_INFO *pFindData = (FILE_UNIX_INFO *)current_entry;
557 filename = &pFindData->FileName[0]; 555 filename = &pFindData->FileName[0];
558 if (cfile->srch_inf.unicode) { 556 if (cfile->srch_inf.unicode) {
559 len = cifs_unicode_bytelen(filename); 557 len = cifs_unicode_bytelen(filename);
@@ -562,30 +560,30 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
562 len = strnlen(filename, 5); 560 len = strnlen(filename, 5);
563 } 561 }
564 } else if (cfile->srch_inf.info_level == SMB_FIND_FILE_DIRECTORY_INFO) { 562 } else if (cfile->srch_inf.info_level == SMB_FIND_FILE_DIRECTORY_INFO) {
565 FILE_DIRECTORY_INFO * pFindData = 563 FILE_DIRECTORY_INFO *pFindData =
566 (FILE_DIRECTORY_INFO *)current_entry; 564 (FILE_DIRECTORY_INFO *)current_entry;
567 filename = &pFindData->FileName[0]; 565 filename = &pFindData->FileName[0];
568 len = le32_to_cpu(pFindData->FileNameLength); 566 len = le32_to_cpu(pFindData->FileNameLength);
569 } else if (cfile->srch_inf.info_level == 567 } else if (cfile->srch_inf.info_level ==
570 SMB_FIND_FILE_FULL_DIRECTORY_INFO) { 568 SMB_FIND_FILE_FULL_DIRECTORY_INFO) {
571 FILE_FULL_DIRECTORY_INFO * pFindData = 569 FILE_FULL_DIRECTORY_INFO *pFindData =
572 (FILE_FULL_DIRECTORY_INFO *)current_entry; 570 (FILE_FULL_DIRECTORY_INFO *)current_entry;
573 filename = &pFindData->FileName[0]; 571 filename = &pFindData->FileName[0];
574 len = le32_to_cpu(pFindData->FileNameLength); 572 len = le32_to_cpu(pFindData->FileNameLength);
575 } else if (cfile->srch_inf.info_level == 573 } else if (cfile->srch_inf.info_level ==
576 SMB_FIND_FILE_ID_FULL_DIR_INFO) { 574 SMB_FIND_FILE_ID_FULL_DIR_INFO) {
577 SEARCH_ID_FULL_DIR_INFO * pFindData = 575 SEARCH_ID_FULL_DIR_INFO *pFindData =
578 (SEARCH_ID_FULL_DIR_INFO *)current_entry; 576 (SEARCH_ID_FULL_DIR_INFO *)current_entry;
579 filename = &pFindData->FileName[0]; 577 filename = &pFindData->FileName[0];
580 len = le32_to_cpu(pFindData->FileNameLength); 578 len = le32_to_cpu(pFindData->FileNameLength);
581 } else if (cfile->srch_inf.info_level == 579 } else if (cfile->srch_inf.info_level ==
582 SMB_FIND_FILE_BOTH_DIRECTORY_INFO) { 580 SMB_FIND_FILE_BOTH_DIRECTORY_INFO) {
583 FILE_BOTH_DIRECTORY_INFO * pFindData = 581 FILE_BOTH_DIRECTORY_INFO *pFindData =
584 (FILE_BOTH_DIRECTORY_INFO *)current_entry; 582 (FILE_BOTH_DIRECTORY_INFO *)current_entry;
585 filename = &pFindData->FileName[0]; 583 filename = &pFindData->FileName[0];
586 len = le32_to_cpu(pFindData->FileNameLength); 584 len = le32_to_cpu(pFindData->FileNameLength);
587 } else if (cfile->srch_inf.info_level == SMB_FIND_FILE_INFO_STANDARD) { 585 } else if (cfile->srch_inf.info_level == SMB_FIND_FILE_INFO_STANDARD) {
588 FIND_FILE_STANDARD_INFO * pFindData = 586 FIND_FILE_STANDARD_INFO *pFindData =
589 (FIND_FILE_STANDARD_INFO *)current_entry; 587 (FIND_FILE_STANDARD_INFO *)current_entry;
590 filename = &pFindData->FileName[0]; 588 filename = &pFindData->FileName[0];
591 len = pFindData->FileNameLength; 589 len = pFindData->FileNameLength;
@@ -666,9 +664,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
666 . and .. for the root of a drive and for those we need 664 . and .. for the root of a drive and for those we need
667 to start two entries earlier */ 665 to start two entries earlier */
668 666
669#ifdef CONFIG_CIFS_DEBUG2
670 dump_cifs_file_struct(file, "In fce "); 667 dump_cifs_file_struct(file, "In fce ");
671#endif
672 if (((index_to_find < cifsFile->srch_inf.index_of_last_entry) && 668 if (((index_to_find < cifsFile->srch_inf.index_of_last_entry) &&
673 is_dir_changed(file)) || 669 is_dir_changed(file)) ||
674 (index_to_find < first_entry_in_buffer)) { 670 (index_to_find < first_entry_in_buffer)) {
@@ -718,7 +714,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
718 pos_in_buf = index_to_find - first_entry_in_buffer; 714 pos_in_buf = index_to_find - first_entry_in_buffer;
719 cFYI(1, ("found entry - pos_in_buf %d", pos_in_buf)); 715 cFYI(1, ("found entry - pos_in_buf %d", pos_in_buf));
720 716
721 for (i=0; (i < (pos_in_buf)) && (current_entry != NULL); i++) { 717 for (i = 0; (i < (pos_in_buf)) && (current_entry != NULL); i++) {
722 /* go entry by entry figuring out which is first */ 718 /* go entry by entry figuring out which is first */
723 current_entry = nxt_dir_entry(current_entry, end_of_smb, 719 current_entry = nxt_dir_entry(current_entry, end_of_smb,
724 cifsFile->srch_inf.info_level); 720 cifsFile->srch_inf.info_level);
@@ -793,7 +789,7 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
793 filename = &pFindData->FileName[0]; 789 filename = &pFindData->FileName[0];
794 len = le32_to_cpu(pFindData->FileNameLength); 790 len = le32_to_cpu(pFindData->FileNameLength);
795 } else if (level == SMB_FIND_FILE_INFO_STANDARD) { 791 } else if (level == SMB_FIND_FILE_INFO_STANDARD) {
796 FIND_FILE_STANDARD_INFO * pFindData = 792 FIND_FILE_STANDARD_INFO *pFindData =
797 (FIND_FILE_STANDARD_INFO *)current_entry; 793 (FIND_FILE_STANDARD_INFO *)current_entry;
798 filename = &pFindData->FileName[0]; 794 filename = &pFindData->FileName[0];
799 /* one byte length, no name conversion */ 795 /* one byte length, no name conversion */
@@ -928,7 +924,7 @@ static int cifs_save_resume_key(const char *current_entry,
928 level = cifsFile->srch_inf.info_level; 924 level = cifsFile->srch_inf.info_level;
929 925
930 if (level == SMB_FIND_FILE_UNIX) { 926 if (level == SMB_FIND_FILE_UNIX) {
931 FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry; 927 FILE_UNIX_INFO *pFindData = (FILE_UNIX_INFO *)current_entry;
932 928
933 filename = &pFindData->FileName[0]; 929 filename = &pFindData->FileName[0];
934 if (cifsFile->srch_inf.unicode) { 930 if (cifsFile->srch_inf.unicode) {
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
index d2153abcba6d..ed150efbe27c 100644
--- a/fs/cifs/sess.c
+++ b/fs/cifs/sess.c
@@ -417,10 +417,6 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
417 417
418 calc_lanman_hash(ses, lnm_session_key); 418 calc_lanman_hash(ses, lnm_session_key);
419 ses->flags |= CIFS_SES_LANMAN; 419 ses->flags |= CIFS_SES_LANMAN;
420/* #ifdef CONFIG_CIFS_DEBUG2
421 cifs_dump_mem("cryptkey: ",ses->server->cryptKey,
422 CIFS_SESS_KEY_SIZE);
423#endif */
424 memcpy(bcc_ptr, (char *)lnm_session_key, CIFS_SESS_KEY_SIZE); 420 memcpy(bcc_ptr, (char *)lnm_session_key, CIFS_SESS_KEY_SIZE);
425 bcc_ptr += CIFS_SESS_KEY_SIZE; 421 bcc_ptr += CIFS_SESS_KEY_SIZE;
426 422
diff --git a/fs/cifs/smbdes.c b/fs/cifs/smbdes.c
index cfa6d21fb4e8..04943c976f98 100644
--- a/fs/cifs/smbdes.c
+++ b/fs/cifs/smbdes.c
@@ -114,42 +114,42 @@ static uchar sbox[8][4][16] = {
114 {{14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7}, 114 {{14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7},
115 {0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8}, 115 {0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8},
116 {4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0}, 116 {4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0},
117 {15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13}}, 117 {15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13} },
118 118
119 {{15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10}, 119 {{15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10},
120 {3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5}, 120 {3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5},
121 {0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15}, 121 {0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15},
122 {13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9}}, 122 {13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9} },
123 123
124 {{10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8}, 124 {{10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8},
125 {13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1}, 125 {13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1},
126 {13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7}, 126 {13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7},
127 {1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12}}, 127 {1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12} },
128 128
129 {{7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15}, 129 {{7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15},
130 {13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9}, 130 {13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9},
131 {10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4}, 131 {10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4},
132 {3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14}}, 132 {3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14} },
133 133
134 {{2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9}, 134 {{2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9},
135 {14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6}, 135 {14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6},
136 {4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14}, 136 {4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14},
137 {11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3}}, 137 {11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3} },
138 138
139 {{12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11}, 139 {{12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11},
140 {10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8}, 140 {10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8},
141 {9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6}, 141 {9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6},
142 {4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13}}, 142 {4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13} },
143 143
144 {{4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1}, 144 {{4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1},
145 {13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6}, 145 {13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6},
146 {1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2}, 146 {1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2},
147 {6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12}}, 147 {6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12} },
148 148
149 {{13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7}, 149 {{13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7},
150 {1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2}, 150 {1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2},
151 {7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8}, 151 {7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8},
152 {2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11}} 152 {2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11} }
153}; 153};
154 154
155static void 155static void
@@ -313,9 +313,8 @@ str_to_key(unsigned char *str, unsigned char *key)
313 key[5] = ((str[4] & 0x1F) << 2) | (str[5] >> 6); 313 key[5] = ((str[4] & 0x1F) << 2) | (str[5] >> 6);
314 key[6] = ((str[5] & 0x3F) << 1) | (str[6] >> 7); 314 key[6] = ((str[5] & 0x3F) << 1) | (str[6] >> 7);
315 key[7] = str[6] & 0x7F; 315 key[7] = str[6] & 0x7F;
316 for (i = 0; i < 8; i++) { 316 for (i = 0; i < 8; i++)
317 key[i] = (key[i] << 1); 317 key[i] = (key[i] << 1);
318 }
319} 318}
320 319
321static void 320static void
@@ -344,9 +343,8 @@ smbhash(unsigned char *out, unsigned char *in, unsigned char *key, int forw)
344 343
345 dohash(outb, inb, keyb, forw); 344 dohash(outb, inb, keyb, forw);
346 345
347 for (i = 0; i < 8; i++) { 346 for (i = 0; i < 8; i++)
348 out[i] = 0; 347 out[i] = 0;
349 }
350 348
351 for (i = 0; i < 64; i++) { 349 for (i = 0; i < 64; i++) {
352 if (outb[i]) 350 if (outb[i])
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index 50b623ad9320..3612d6c0a0bb 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * fs/cifs/transport.c 2 * fs/cifs/transport.c
3 * 3 *
4 * Copyright (C) International Business Machines Corp., 2002,2007 4 * Copyright (C) International Business Machines Corp., 2002,2008
5 * Author(s): Steve French (sfrench@us.ibm.com) 5 * Author(s): Steve French (sfrench@us.ibm.com)
6 * Jeremy Allison (jra@samba.org) 2006. 6 * Jeremy Allison (jra@samba.org) 2006.
7 * 7 *
@@ -358,9 +358,9 @@ static int allocate_mid(struct cifsSesInfo *ses, struct smb_hdr *in_buf,
358 } else if (ses->status != CifsGood) { 358 } else if (ses->status != CifsGood) {
359 /* check if SMB session is bad because we are setting it up */ 359 /* check if SMB session is bad because we are setting it up */
360 if ((in_buf->Command != SMB_COM_SESSION_SETUP_ANDX) && 360 if ((in_buf->Command != SMB_COM_SESSION_SETUP_ANDX) &&
361 (in_buf->Command != SMB_COM_NEGOTIATE)) { 361 (in_buf->Command != SMB_COM_NEGOTIATE))
362 return -EAGAIN; 362 return -EAGAIN;
363 } /* else ok - we are setting up session */ 363 /* else ok - we are setting up session */
364 } 364 }
365 *ppmidQ = AllocMidQEntry(in_buf, ses); 365 *ppmidQ = AllocMidQEntry(in_buf, ses);
366 if (*ppmidQ == NULL) 366 if (*ppmidQ == NULL)
@@ -437,9 +437,8 @@ SendReceiveNoRsp(const unsigned int xid, struct cifsSesInfo *ses,
437 iov[0].iov_len = in_buf->smb_buf_length + 4; 437 iov[0].iov_len = in_buf->smb_buf_length + 4;
438 flags |= CIFS_NO_RESP; 438 flags |= CIFS_NO_RESP;
439 rc = SendReceive2(xid, ses, iov, 1, &resp_buf_type, flags); 439 rc = SendReceive2(xid, ses, iov, 1, &resp_buf_type, flags);
440#ifdef CONFIG_CIFS_DEBUG2 440 cFYI(DBG2, ("SendRcvNoRsp flags %d rc %d", flags, rc));
441 cFYI(1, ("SendRcvNoR flags %d rc %d", flags, rc)); 441
442#endif
443 return rc; 442 return rc;
444} 443}
445 444
diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c
index 54e8ef96cb79..8cd6a445b017 100644
--- a/fs/cifs/xattr.c
+++ b/fs/cifs/xattr.c
@@ -139,9 +139,9 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name,
139 } else if (strncmp(ea_name, CIFS_XATTR_USER_PREFIX, 5) == 0) { 139 } else if (strncmp(ea_name, CIFS_XATTR_USER_PREFIX, 5) == 0) {
140 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) 140 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
141 goto set_ea_exit; 141 goto set_ea_exit;
142 if (strncmp(ea_name, CIFS_XATTR_DOS_ATTRIB, 14) == 0) { 142 if (strncmp(ea_name, CIFS_XATTR_DOS_ATTRIB, 14) == 0)
143 cFYI(1, ("attempt to set cifs inode metadata")); 143 cFYI(1, ("attempt to set cifs inode metadata"));
144 } 144
145 ea_name += 5; /* skip past user. prefix */ 145 ea_name += 5; /* skip past user. prefix */
146 rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, ea_value, 146 rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, ea_value,
147 (__u16)value_size, cifs_sb->local_nls, 147 (__u16)value_size, cifs_sb->local_nls,
@@ -262,7 +262,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name,
262 cifs_sb->mnt_cifs_flags & 262 cifs_sb->mnt_cifs_flags &
263 CIFS_MOUNT_MAP_SPECIAL_CHR); 263 CIFS_MOUNT_MAP_SPECIAL_CHR);
264#ifdef CONFIG_CIFS_EXPERIMENTAL 264#ifdef CONFIG_CIFS_EXPERIMENTAL
265 else if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) { 265 else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {
266 __u16 fid; 266 __u16 fid;
267 int oplock = FALSE; 267 int oplock = FALSE;
268 struct cifs_ntsd *pacl = NULL; 268 struct cifs_ntsd *pacl = NULL;
@@ -303,11 +303,10 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name,
303 } else if (strncmp(ea_name, 303 } else if (strncmp(ea_name,
304 CIFS_XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN) == 0) { 304 CIFS_XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN) == 0) {
305 cFYI(1, ("Security xattr namespace not supported yet")); 305 cFYI(1, ("Security xattr namespace not supported yet"));
306 } else { 306 } else
307 cFYI(1, 307 cFYI(1,
308 ("illegal xattr request %s (only user namespace supported)", 308 ("illegal xattr request %s (only user namespace supported)",
309 ea_name)); 309 ea_name));
310 }
311 310
312 /* We could add an additional check for streams ie 311 /* We could add an additional check for streams ie
313 if proc/fs/cifs/streamstoxattr is set then 312 if proc/fs/cifs/streamstoxattr is set then
diff --git a/fs/exec.c b/fs/exec.c
index a44b142fb460..54a0a557b678 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -173,8 +173,15 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
173 return NULL; 173 return NULL;
174 174
175 if (write) { 175 if (write) {
176 struct rlimit *rlim = current->signal->rlim;
177 unsigned long size = bprm->vma->vm_end - bprm->vma->vm_start; 176 unsigned long size = bprm->vma->vm_end - bprm->vma->vm_start;
177 struct rlimit *rlim;
178
179 /*
180 * We've historically supported up to 32 pages (ARG_MAX)
181 * of argument strings even with small stacks
182 */
183 if (size <= ARG_MAX)
184 return page;
178 185
179 /* 186 /*
180 * Limit to 1/4-th the stack size for the argv+env strings. 187 * Limit to 1/4-th the stack size for the argv+env strings.
@@ -183,6 +190,7 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
183 * - the program will have a reasonable amount of stack left 190 * - the program will have a reasonable amount of stack left
184 * to work from. 191 * to work from.
185 */ 192 */
193 rlim = current->signal->rlim;
186 if (size > rlim[RLIMIT_STACK].rlim_cur / 4) { 194 if (size > rlim[RLIMIT_STACK].rlim_cur / 4) {
187 put_page(page); 195 put_page(page);
188 return NULL; 196 return NULL;
diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c
index 038ed7436199..c6cbb6cd59b2 100644
--- a/fs/jbd/transaction.c
+++ b/fs/jbd/transaction.c
@@ -369,7 +369,7 @@ out:
369 369
370 370
371/** 371/**
372 * int journal_restart() - restart a handle . 372 * int journal_restart() - restart a handle.
373 * @handle: handle to restart 373 * @handle: handle to restart
374 * @nblocks: nr credits requested 374 * @nblocks: nr credits requested
375 * 375 *
@@ -844,8 +844,7 @@ out:
844} 844}
845 845
846/** 846/**
847 * int journal_get_undo_access() - Notify intent to modify metadata with 847 * int journal_get_undo_access() - Notify intent to modify metadata with non-rewindable consequences
848 * non-rewindable consequences
849 * @handle: transaction 848 * @handle: transaction
850 * @bh: buffer to undo 849 * @bh: buffer to undo
851 * @credits: store the number of taken credits here (if not NULL) 850 * @credits: store the number of taken credits here (if not NULL)
@@ -921,12 +920,14 @@ out:
921} 920}
922 921
923/** 922/**
924 * int journal_dirty_data() - mark a buffer as containing dirty data which 923 * int journal_dirty_data() - mark a buffer as containing dirty data to be flushed
925 * needs to be flushed before we can commit the
926 * current transaction.
927 * @handle: transaction 924 * @handle: transaction
928 * @bh: bufferhead to mark 925 * @bh: bufferhead to mark
929 * 926 *
927 * Description:
928 * Mark a buffer as containing dirty data which needs to be flushed before
929 * we can commit the current transaction.
930 *
930 * The buffer is placed on the transaction's data list and is marked as 931 * The buffer is placed on the transaction's data list and is marked as
931 * belonging to the transaction. 932 * belonging to the transaction.
932 * 933 *
@@ -1098,11 +1099,11 @@ no_journal:
1098} 1099}
1099 1100
1100/** 1101/**
1101 * int journal_dirty_metadata() - mark a buffer as containing dirty metadata 1102 * int journal_dirty_metadata() - mark a buffer as containing dirty metadata
1102 * @handle: transaction to add buffer to. 1103 * @handle: transaction to add buffer to.
1103 * @bh: buffer to mark 1104 * @bh: buffer to mark
1104 * 1105 *
1105 * mark dirty metadata which needs to be journaled as part of the current 1106 * Mark dirty metadata which needs to be journaled as part of the current
1106 * transaction. 1107 * transaction.
1107 * 1108 *
1108 * The buffer is placed on the transaction's metadata list and is marked 1109 * The buffer is placed on the transaction's metadata list and is marked
diff --git a/fs/mpage.c b/fs/mpage.c
index 5df564366f36..235e4d3873a8 100644
--- a/fs/mpage.c
+++ b/fs/mpage.c
@@ -325,16 +325,12 @@ confused:
325} 325}
326 326
327/** 327/**
328 * mpage_readpages - populate an address space with some pages, and 328 * mpage_readpages - populate an address space with some pages & start reads against them
329 * start reads against them.
330 *
331 * @mapping: the address_space 329 * @mapping: the address_space
332 * @pages: The address of a list_head which contains the target pages. These 330 * @pages: The address of a list_head which contains the target pages. These
333 * pages have their ->index populated and are otherwise uninitialised. 331 * pages have their ->index populated and are otherwise uninitialised.
334 *
335 * The page at @pages->prev has the lowest file offset, and reads should be 332 * The page at @pages->prev has the lowest file offset, and reads should be
336 * issued in @pages->prev to @pages->next order. 333 * issued in @pages->prev to @pages->next order.
337 *
338 * @nr_pages: The number of pages at *@pages 334 * @nr_pages: The number of pages at *@pages
339 * @get_block: The filesystem's block mapper function. 335 * @get_block: The filesystem's block mapper function.
340 * 336 *
@@ -360,6 +356,7 @@ confused:
360 * So an mpage read of the first 16 blocks of an ext2 file will cause I/O to be 356 * So an mpage read of the first 16 blocks of an ext2 file will cause I/O to be
361 * submitted in the following order: 357 * submitted in the following order:
362 * 12 0 1 2 3 4 5 6 7 8 9 10 11 13 14 15 16 358 * 12 0 1 2 3 4 5 6 7 8 9 10 11 13 14 15 16
359 *
363 * because the indirect block has to be read to get the mappings of blocks 360 * because the indirect block has to be read to get the mappings of blocks
364 * 13,14,15,16. Obviously, this impacts performance. 361 * 13,14,15,16. Obviously, this impacts performance.
365 * 362 *
@@ -656,9 +653,7 @@ out:
656} 653}
657 654
658/** 655/**
659 * mpage_writepages - walk the list of dirty pages of the given 656 * mpage_writepages - walk the list of dirty pages of the given address space & writepage() all of them
660 * address space and writepage() all of them.
661 *
662 * @mapping: address space structure to write 657 * @mapping: address space structure to write
663 * @wbc: subtract the number of written pages from *@wbc->nr_to_write 658 * @wbc: subtract the number of written pages from *@wbc->nr_to_write
664 * @get_block: the filesystem's block mapper function. 659 * @get_block: the filesystem's block mapper function.
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index 468805d40e2b..2d563979cb02 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -32,6 +32,7 @@
32#include <linux/interrupt.h> 32#include <linux/interrupt.h>
33#include <linux/swap.h> 33#include <linux/swap.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/genhd.h>
35#include <linux/smp.h> 36#include <linux/smp.h>
36#include <linux/signal.h> 37#include <linux/signal.h>
37#include <linux/module.h> 38#include <linux/module.h>
@@ -377,7 +378,6 @@ static int stram_read_proc(char *page, char **start, off_t off,
377#endif 378#endif
378 379
379#ifdef CONFIG_BLOCK 380#ifdef CONFIG_BLOCK
380extern const struct seq_operations partitions_op;
381static int partitions_open(struct inode *inode, struct file *file) 381static int partitions_open(struct inode *inode, struct file *file)
382{ 382{
383 return seq_open(file, &partitions_op); 383 return seq_open(file, &partitions_op);
@@ -389,7 +389,6 @@ static const struct file_operations proc_partitions_operations = {
389 .release = seq_release, 389 .release = seq_release,
390}; 390};
391 391
392extern const struct seq_operations diskstats_op;
393static int diskstats_open(struct inode *inode, struct file *file) 392static int diskstats_open(struct inode *inode, struct file *file)
394{ 393{
395 return seq_open(file, &diskstats_op); 394 return seq_open(file, &diskstats_op);
diff --git a/fs/splice.c b/fs/splice.c
index 9b559ee711a8..0670c915cd35 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -1669,6 +1669,13 @@ static int link_pipe(struct pipe_inode_info *ipipe,
1669 i++; 1669 i++;
1670 } while (len); 1670 } while (len);
1671 1671
1672 /*
1673 * return EAGAIN if we have the potential of some data in the
1674 * future, otherwise just return 0
1675 */
1676 if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
1677 ret = -EAGAIN;
1678
1672 inode_double_unlock(ipipe->inode, opipe->inode); 1679 inode_double_unlock(ipipe->inode, opipe->inode);
1673 1680
1674 /* 1681 /*
@@ -1709,11 +1716,8 @@ static long do_tee(struct file *in, struct file *out, size_t len,
1709 ret = link_ipipe_prep(ipipe, flags); 1716 ret = link_ipipe_prep(ipipe, flags);
1710 if (!ret) { 1717 if (!ret) {
1711 ret = link_opipe_prep(opipe, flags); 1718 ret = link_opipe_prep(opipe, flags);
1712 if (!ret) { 1719 if (!ret)
1713 ret = link_pipe(ipipe, opipe, len, flags); 1720 ret = link_pipe(ipipe, opipe, len, flags);
1714 if (!ret && (flags & SPLICE_F_NONBLOCK))
1715 ret = -EAGAIN;
1716 }
1717 } 1721 }
1718 } 1722 }
1719 1723
diff --git a/include/asm-m68k/unistd.h b/include/asm-m68k/unistd.h
index 87f77b119317..e72ba563f102 100644
--- a/include/asm-m68k/unistd.h
+++ b/include/asm-m68k/unistd.h
@@ -320,13 +320,15 @@
320#define __NR_epoll_pwait 315 320#define __NR_epoll_pwait 315
321#define __NR_utimensat 316 321#define __NR_utimensat 316
322#define __NR_signalfd 317 322#define __NR_signalfd 317
323#define __NR_timerfd 318 323#define __NR_timerfd_create 318
324#define __NR_eventfd 319 324#define __NR_eventfd 319
325#define __NR_fallocate 320 325#define __NR_fallocate 320
326#define __NR_timerfd_settime 321
327#define __NR_timerfd_gettime 322
326 328
327#ifdef __KERNEL__ 329#ifdef __KERNEL__
328 330
329#define NR_syscalls 321 331#define NR_syscalls 323
330 332
331#define __ARCH_WANT_IPC_PARSE_VERSION 333#define __ARCH_WANT_IPC_PARSE_VERSION
332#define __ARCH_WANT_OLD_READDIR 334#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-m68knommu/machdep.h b/include/asm-m68knommu/machdep.h
index 1cf26d240d83..de9f47a51cc2 100644
--- a/include/asm-m68knommu/machdep.h
+++ b/include/asm-m68knommu/machdep.h
@@ -21,4 +21,6 @@ extern void (*mach_power_off)( void );
21 21
22extern void config_BSP(char *command, int len); 22extern void config_BSP(char *command, int len);
23 23
24extern void do_IRQ(int irq, struct pt_regs *fp);
25
24#endif /* _M68KNOMMU_MACHDEP_H */ 26#endif /* _M68KNOMMU_MACHDEP_H */
diff --git a/include/asm-m68knommu/unistd.h b/include/asm-m68knommu/unistd.h
index 27c2f9bb4dbd..4ba98b9c5d79 100644
--- a/include/asm-m68knommu/unistd.h
+++ b/include/asm-m68knommu/unistd.h
@@ -321,13 +321,15 @@
321#define __NR_epoll_pwait 315 321#define __NR_epoll_pwait 315
322#define __NR_utimensat 316 322#define __NR_utimensat 316
323#define __NR_signalfd 317 323#define __NR_signalfd 317
324#define __NR_timerfd 318 324#define __NR_timerfd_create 318
325#define __NR_eventfd 319 325#define __NR_eventfd 319
326#define __NR_fallocate 320 326#define __NR_fallocate 320
327#define __NR_timerfd_settime 321
328#define __NR_timerfd_gettime 322
327 329
328#ifdef __KERNEL__ 330#ifdef __KERNEL__
329 331
330#define NR_syscalls 321 332#define NR_syscalls 323
331 333
332#define __ARCH_WANT_IPC_PARSE_VERSION 334#define __ARCH_WANT_IPC_PARSE_VERSION
333#define __ARCH_WANT_OLD_READDIR 335#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-powerpc/reg.h b/include/asm-powerpc/reg.h
index 0d6238987df8..edc0cfd7f6e2 100644
--- a/include/asm-powerpc/reg.h
+++ b/include/asm-powerpc/reg.h
@@ -153,6 +153,9 @@
153#define CTRL_RUNLATCH 0x1 153#define CTRL_RUNLATCH 0x1
154#define SPRN_DABR 0x3F5 /* Data Address Breakpoint Register */ 154#define SPRN_DABR 0x3F5 /* Data Address Breakpoint Register */
155#define DABR_TRANSLATION (1UL << 2) 155#define DABR_TRANSLATION (1UL << 2)
156#define SPRN_DABRX 0x3F7 /* Data Address Breakpoint Register Extension */
157#define DABRX_USER (1UL << 0)
158#define DABRX_KERNEL (1UL << 1)
156#define SPRN_DAR 0x013 /* Data Address Register */ 159#define SPRN_DAR 0x013 /* Data Address Register */
157#define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */ 160#define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
158#define DSISR_NOHPTE 0x40000000 /* no translation found */ 161#define DSISR_NOHPTE 0x40000000 /* no translation found */
diff --git a/include/asm-x86/pgtable_32.h b/include/asm-x86/pgtable_32.h
index b478efa971e0..a842c7222b1e 100644
--- a/include/asm-x86/pgtable_32.h
+++ b/include/asm-x86/pgtable_32.h
@@ -91,9 +91,7 @@ extern unsigned long pg0[];
91/* To avoid harmful races, pmd_none(x) should check only the lower when PAE */ 91/* To avoid harmful races, pmd_none(x) should check only the lower when PAE */
92#define pmd_none(x) (!(unsigned long)pmd_val(x)) 92#define pmd_none(x) (!(unsigned long)pmd_val(x))
93#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT) 93#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT)
94#define pmd_bad(x) ((pmd_val(x) \ 94#define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE)
95 & ~(PAGE_MASK | _PAGE_USER | _PAGE_PSE | _PAGE_NX)) \
96 != _KERNPG_TABLE)
97 95
98 96
99#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) 97#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))
diff --git a/include/asm-x86/pgtable_64.h b/include/asm-x86/pgtable_64.h
index 0a9258333cbd..0a0b77bc736a 100644
--- a/include/asm-x86/pgtable_64.h
+++ b/include/asm-x86/pgtable_64.h
@@ -153,14 +153,12 @@ static inline unsigned long pgd_bad(pgd_t pgd)
153 153
154static inline unsigned long pud_bad(pud_t pud) 154static inline unsigned long pud_bad(pud_t pud)
155{ 155{
156 return pud_val(pud) & 156 return pud_val(pud) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER);
157 ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER | _PAGE_PSE | _PAGE_NX);
158} 157}
159 158
160static inline unsigned long pmd_bad(pmd_t pmd) 159static inline unsigned long pmd_bad(pmd_t pmd)
161{ 160{
162 return pmd_val(pmd) & 161 return pmd_val(pmd) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER);
163 ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER | _PAGE_PSE | _PAGE_NX);
164} 162}
165 163
166#define pte_none(x) (!pte_val(x)) 164#define pte_none(x) (!pte_val(x))
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 6fe67d1939c2..6f79d40dd3c0 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -216,8 +216,8 @@ struct request {
216 unsigned int cmd_len; 216 unsigned int cmd_len;
217 unsigned char cmd[BLK_MAX_CDB]; 217 unsigned char cmd[BLK_MAX_CDB];
218 218
219 unsigned int raw_data_len;
220 unsigned int data_len; 219 unsigned int data_len;
220 unsigned int extra_len; /* length of alignment and padding */
221 unsigned int sense_len; 221 unsigned int sense_len;
222 void *data; 222 void *data;
223 void *sense; 223 void *sense;
@@ -362,6 +362,7 @@ struct request_queue
362 unsigned long seg_boundary_mask; 362 unsigned long seg_boundary_mask;
363 void *dma_drain_buffer; 363 void *dma_drain_buffer;
364 unsigned int dma_drain_size; 364 unsigned int dma_drain_size;
365 unsigned int dma_pad_mask;
365 unsigned int dma_alignment; 366 unsigned int dma_alignment;
366 367
367 struct blk_queue_tag *queue_tags; 368 struct blk_queue_tag *queue_tags;
@@ -701,6 +702,7 @@ extern void blk_queue_max_hw_segments(struct request_queue *, unsigned short);
701extern void blk_queue_max_segment_size(struct request_queue *, unsigned int); 702extern void blk_queue_max_segment_size(struct request_queue *, unsigned int);
702extern void blk_queue_hardsect_size(struct request_queue *, unsigned short); 703extern void blk_queue_hardsect_size(struct request_queue *, unsigned short);
703extern void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b); 704extern void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b);
705extern void blk_queue_dma_pad(struct request_queue *, unsigned int);
704extern int blk_queue_dma_drain(struct request_queue *q, 706extern int blk_queue_dma_drain(struct request_queue *q,
705 dma_drain_needed_fn *dma_drain_needed, 707 dma_drain_needed_fn *dma_drain_needed,
706 void *buf, unsigned int size); 708 void *buf, unsigned int size);
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 09a3b18918c7..32c2ac49a070 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -18,11 +18,13 @@
18#define dev_to_disk(device) container_of(device, struct gendisk, dev) 18#define dev_to_disk(device) container_of(device, struct gendisk, dev)
19#define dev_to_part(device) container_of(device, struct hd_struct, dev) 19#define dev_to_part(device) container_of(device, struct hd_struct, dev)
20 20
21extern struct device_type disk_type;
22extern struct device_type part_type; 21extern struct device_type part_type;
23extern struct kobject *block_depr; 22extern struct kobject *block_depr;
24extern struct class block_class; 23extern struct class block_class;
25 24
25extern const struct seq_operations partitions_op;
26extern const struct seq_operations diskstats_op;
27
26enum { 28enum {
27/* These three have identical behaviour; use the second one if DOS FDISK gets 29/* These three have identical behaviour; use the second one if DOS FDISK gets
28 confused about extended/logical partitions starting past cylinder 1023. */ 30 confused about extended/logical partitions starting past cylinder 1023. */
@@ -556,7 +558,6 @@ extern struct gendisk *alloc_disk_node(int minors, int node_id);
556extern struct gendisk *alloc_disk(int minors); 558extern struct gendisk *alloc_disk(int minors);
557extern struct kobject *get_disk(struct gendisk *disk); 559extern struct kobject *get_disk(struct gendisk *disk);
558extern void put_disk(struct gendisk *disk); 560extern void put_disk(struct gendisk *disk);
559extern void genhd_media_change_notify(struct gendisk *disk);
560extern void blk_register_region(dev_t devt, unsigned long range, 561extern void blk_register_region(dev_t devt, unsigned long range,
561 struct module *module, 562 struct module *module,
562 struct kobject *(*probe)(dev_t, int *, void *), 563 struct kobject *(*probe)(dev_t, int *, void *),
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index bfee0bd1d435..34023c65d466 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -64,10 +64,7 @@ struct page {
64#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS 64#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
65 spinlock_t ptl; 65 spinlock_t ptl;
66#endif 66#endif
67 struct { 67 struct kmem_cache *slab; /* SLUB: Pointer to slab */
68 struct kmem_cache *slab; /* SLUB: Pointer to slab */
69 void *end; /* SLUB: end marker */
70 };
71 struct page *first_page; /* Compound tail pages */ 68 struct page *first_page; /* Compound tail pages */
72 }; 69 };
73 union { 70 union {
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index 57deecc79d52..b00c1c73eb0a 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -61,7 +61,7 @@ struct kmem_cache {
61 int size; /* The size of an object including meta data */ 61 int size; /* The size of an object including meta data */
62 int objsize; /* The size of an object without meta data */ 62 int objsize; /* The size of an object without meta data */
63 int offset; /* Free pointer offset. */ 63 int offset; /* Free pointer offset. */
64 int order; 64 int order; /* Current preferred allocation order */
65 65
66 /* 66 /*
67 * Avoid an extra cache line for UP, SMP and for the node local to 67 * Avoid an extra cache line for UP, SMP and for the node local to
@@ -138,11 +138,11 @@ static __always_inline int kmalloc_index(size_t size)
138 if (size <= 512) return 9; 138 if (size <= 512) return 9;
139 if (size <= 1024) return 10; 139 if (size <= 1024) return 10;
140 if (size <= 2 * 1024) return 11; 140 if (size <= 2 * 1024) return 11;
141 if (size <= 4 * 1024) return 12;
141/* 142/*
142 * The following is only needed to support architectures with a larger page 143 * The following is only needed to support architectures with a larger page
143 * size than 4k. 144 * size than 4k.
144 */ 145 */
145 if (size <= 4 * 1024) return 12;
146 if (size <= 8 * 1024) return 13; 146 if (size <= 8 * 1024) return 13;
147 if (size <= 16 * 1024) return 14; 147 if (size <= 16 * 1024) return 14;
148 if (size <= 32 * 1024) return 15; 148 if (size <= 32 * 1024) return 15;
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 2372e2e6b527..5bd3ae8aaaf4 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -781,8 +781,7 @@ static inline int usb_endpoint_is_isoc_out(
781 .idVendor = (vend), \ 781 .idVendor = (vend), \
782 .idProduct = (prod) 782 .idProduct = (prod)
783/** 783/**
784 * USB_DEVICE_VER - macro used to describe a specific usb device with a 784 * USB_DEVICE_VER - describe a specific usb device with a version range
785 * version range
786 * @vend: the 16 bit USB Vendor ID 785 * @vend: the 16 bit USB Vendor ID
787 * @prod: the 16 bit USB Product ID 786 * @prod: the 16 bit USB Product ID
788 * @lo: the bcdDevice_lo value 787 * @lo: the bcdDevice_lo value
@@ -799,8 +798,7 @@ static inline int usb_endpoint_is_isoc_out(
799 .bcdDevice_hi = (hi) 798 .bcdDevice_hi = (hi)
800 799
801/** 800/**
802 * USB_DEVICE_INTERFACE_PROTOCOL - macro used to describe a usb 801 * USB_DEVICE_INTERFACE_PROTOCOL - describe a usb device with a specific interface protocol
803 * device with a specific interface protocol
804 * @vend: the 16 bit USB Vendor ID 802 * @vend: the 16 bit USB Vendor ID
805 * @prod: the 16 bit USB Product ID 803 * @prod: the 16 bit USB Product ID
806 * @pr: bInterfaceProtocol value 804 * @pr: bInterfaceProtocol value
@@ -846,8 +844,7 @@ static inline int usb_endpoint_is_isoc_out(
846 .bInterfaceProtocol = (pr) 844 .bInterfaceProtocol = (pr)
847 845
848/** 846/**
849 * USB_DEVICE_AND_INTERFACE_INFO - macro used to describe a specific usb device 847 * USB_DEVICE_AND_INTERFACE_INFO - describe a specific usb device with a class of usb interfaces
850 * with a class of usb interfaces
851 * @vend: the 16 bit USB Vendor ID 848 * @vend: the 16 bit USB Vendor ID
852 * @prod: the 16 bit USB Product ID 849 * @prod: the 16 bit USB Product ID
853 * @cl: bInterfaceClass value 850 * @cl: bInterfaceClass value
diff --git a/kernel/exit.c b/kernel/exit.c
index 506a957b665a..cd20bf07e9e3 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -214,20 +214,19 @@ struct pid *session_of_pgrp(struct pid *pgrp)
214static int will_become_orphaned_pgrp(struct pid *pgrp, struct task_struct *ignored_task) 214static int will_become_orphaned_pgrp(struct pid *pgrp, struct task_struct *ignored_task)
215{ 215{
216 struct task_struct *p; 216 struct task_struct *p;
217 int ret = 1;
218 217
219 do_each_pid_task(pgrp, PIDTYPE_PGID, p) { 218 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
220 if (p == ignored_task 219 if ((p == ignored_task) ||
221 || p->exit_state 220 (p->exit_state && thread_group_empty(p)) ||
222 || is_global_init(p->real_parent)) 221 is_global_init(p->real_parent))
223 continue; 222 continue;
223
224 if (task_pgrp(p->real_parent) != pgrp && 224 if (task_pgrp(p->real_parent) != pgrp &&
225 task_session(p->real_parent) == task_session(p)) { 225 task_session(p->real_parent) == task_session(p))
226 ret = 0; 226 return 0;
227 break;
228 }
229 } while_each_pid_task(pgrp, PIDTYPE_PGID, p); 227 } while_each_pid_task(pgrp, PIDTYPE_PGID, p);
230 return ret; /* (sighing) "Often!" */ 228
229 return 1;
231} 230}
232 231
233int is_current_pgrp_orphaned(void) 232int is_current_pgrp_orphaned(void)
@@ -255,6 +254,37 @@ static int has_stopped_jobs(struct pid *pgrp)
255 return retval; 254 return retval;
256} 255}
257 256
257/*
258 * Check to see if any process groups have become orphaned as
259 * a result of our exiting, and if they have any stopped jobs,
260 * send them a SIGHUP and then a SIGCONT. (POSIX 3.2.2.2)
261 */
262static void
263kill_orphaned_pgrp(struct task_struct *tsk, struct task_struct *parent)
264{
265 struct pid *pgrp = task_pgrp(tsk);
266 struct task_struct *ignored_task = tsk;
267
268 if (!parent)
269 /* exit: our father is in a different pgrp than
270 * we are and we were the only connection outside.
271 */
272 parent = tsk->real_parent;
273 else
274 /* reparent: our child is in a different pgrp than
275 * we are, and it was the only connection outside.
276 */
277 ignored_task = NULL;
278
279 if (task_pgrp(parent) != pgrp &&
280 task_session(parent) == task_session(tsk) &&
281 will_become_orphaned_pgrp(pgrp, ignored_task) &&
282 has_stopped_jobs(pgrp)) {
283 __kill_pgrp_info(SIGHUP, SEND_SIG_PRIV, pgrp);
284 __kill_pgrp_info(SIGCONT, SEND_SIG_PRIV, pgrp);
285 }
286}
287
258/** 288/**
259 * reparent_to_kthreadd - Reparent the calling kernel thread to kthreadd 289 * reparent_to_kthreadd - Reparent the calling kernel thread to kthreadd
260 * 290 *
@@ -635,22 +665,7 @@ reparent_thread(struct task_struct *p, struct task_struct *father, int traced)
635 p->exit_signal != -1 && thread_group_empty(p)) 665 p->exit_signal != -1 && thread_group_empty(p))
636 do_notify_parent(p, p->exit_signal); 666 do_notify_parent(p, p->exit_signal);
637 667
638 /* 668 kill_orphaned_pgrp(p, father);
639 * process group orphan check
640 * Case ii: Our child is in a different pgrp
641 * than we are, and it was the only connection
642 * outside, so the child pgrp is now orphaned.
643 */
644 if ((task_pgrp(p) != task_pgrp(father)) &&
645 (task_session(p) == task_session(father))) {
646 struct pid *pgrp = task_pgrp(p);
647
648 if (will_become_orphaned_pgrp(pgrp, NULL) &&
649 has_stopped_jobs(pgrp)) {
650 __kill_pgrp_info(SIGHUP, SEND_SIG_PRIV, pgrp);
651 __kill_pgrp_info(SIGCONT, SEND_SIG_PRIV, pgrp);
652 }
653 }
654} 669}
655 670
656/* 671/*
@@ -735,11 +750,9 @@ static void forget_original_parent(struct task_struct *father)
735 * Send signals to all our closest relatives so that they know 750 * Send signals to all our closest relatives so that they know
736 * to properly mourn us.. 751 * to properly mourn us..
737 */ 752 */
738static void exit_notify(struct task_struct *tsk) 753static void exit_notify(struct task_struct *tsk, int group_dead)
739{ 754{
740 int state; 755 int state;
741 struct task_struct *t;
742 struct pid *pgrp;
743 756
744 /* 757 /*
745 * This does two things: 758 * This does two things:
@@ -753,25 +766,8 @@ static void exit_notify(struct task_struct *tsk)
753 exit_task_namespaces(tsk); 766 exit_task_namespaces(tsk);
754 767
755 write_lock_irq(&tasklist_lock); 768 write_lock_irq(&tasklist_lock);
756 /* 769 if (group_dead)
757 * Check to see if any process groups have become orphaned 770 kill_orphaned_pgrp(tsk->group_leader, NULL);
758 * as a result of our exiting, and if they have any stopped
759 * jobs, send them a SIGHUP and then a SIGCONT. (POSIX 3.2.2.2)
760 *
761 * Case i: Our father is in a different pgrp than we are
762 * and we were the only connection outside, so our pgrp
763 * is about to become orphaned.
764 */
765 t = tsk->real_parent;
766
767 pgrp = task_pgrp(tsk);
768 if ((task_pgrp(t) != pgrp) &&
769 (task_session(t) == task_session(tsk)) &&
770 will_become_orphaned_pgrp(pgrp, tsk) &&
771 has_stopped_jobs(pgrp)) {
772 __kill_pgrp_info(SIGHUP, SEND_SIG_PRIV, pgrp);
773 __kill_pgrp_info(SIGCONT, SEND_SIG_PRIV, pgrp);
774 }
775 771
776 /* Let father know we died 772 /* Let father know we died
777 * 773 *
@@ -788,8 +784,8 @@ static void exit_notify(struct task_struct *tsk)
788 * the same after a fork. 784 * the same after a fork.
789 */ 785 */
790 if (tsk->exit_signal != SIGCHLD && tsk->exit_signal != -1 && 786 if (tsk->exit_signal != SIGCHLD && tsk->exit_signal != -1 &&
791 ( tsk->parent_exec_id != t->self_exec_id || 787 (tsk->parent_exec_id != tsk->real_parent->self_exec_id ||
792 tsk->self_exec_id != tsk->parent_exec_id) 788 tsk->self_exec_id != tsk->parent_exec_id)
793 && !capable(CAP_KILL)) 789 && !capable(CAP_KILL))
794 tsk->exit_signal = SIGCHLD; 790 tsk->exit_signal = SIGCHLD;
795 791
@@ -986,7 +982,7 @@ NORET_TYPE void do_exit(long code)
986 module_put(tsk->binfmt->module); 982 module_put(tsk->binfmt->module);
987 983
988 proc_exit_connector(tsk); 984 proc_exit_connector(tsk);
989 exit_notify(tsk); 985 exit_notify(tsk, group_dead);
990#ifdef CONFIG_NUMA 986#ifdef CONFIG_NUMA
991 mpol_free(tsk->mempolicy); 987 mpol_free(tsk->mempolicy);
992 tsk->mempolicy = NULL; 988 tsk->mempolicy = NULL;
diff --git a/kernel/power/process.c b/kernel/power/process.c
index 7c2118f9597f..f1d0b345c9ba 100644
--- a/kernel/power/process.c
+++ b/kernel/power/process.c
@@ -75,22 +75,15 @@ void refrigerator(void)
75 __set_current_state(save); 75 __set_current_state(save);
76} 76}
77 77
78static void fake_signal_wake_up(struct task_struct *p, int resume) 78static void fake_signal_wake_up(struct task_struct *p)
79{ 79{
80 unsigned long flags; 80 unsigned long flags;
81 81
82 spin_lock_irqsave(&p->sighand->siglock, flags); 82 spin_lock_irqsave(&p->sighand->siglock, flags);
83 signal_wake_up(p, resume); 83 signal_wake_up(p, 0);
84 spin_unlock_irqrestore(&p->sighand->siglock, flags); 84 spin_unlock_irqrestore(&p->sighand->siglock, flags);
85} 85}
86 86
87static void send_fake_signal(struct task_struct *p)
88{
89 if (task_is_stopped(p))
90 force_sig_specific(SIGSTOP, p);
91 fake_signal_wake_up(p, task_is_stopped(p));
92}
93
94static int has_mm(struct task_struct *p) 87static int has_mm(struct task_struct *p)
95{ 88{
96 return (p->mm && !(p->flags & PF_BORROWED_MM)); 89 return (p->mm && !(p->flags & PF_BORROWED_MM));
@@ -121,7 +114,7 @@ static int freeze_task(struct task_struct *p, int with_mm_only)
121 if (freezing(p)) { 114 if (freezing(p)) {
122 if (has_mm(p)) { 115 if (has_mm(p)) {
123 if (!signal_pending(p)) 116 if (!signal_pending(p))
124 fake_signal_wake_up(p, 0); 117 fake_signal_wake_up(p);
125 } else { 118 } else {
126 if (with_mm_only) 119 if (with_mm_only)
127 ret = 0; 120 ret = 0;
@@ -135,7 +128,7 @@ static int freeze_task(struct task_struct *p, int with_mm_only)
135 } else { 128 } else {
136 if (has_mm(p)) { 129 if (has_mm(p)) {
137 set_freeze_flag(p); 130 set_freeze_flag(p);
138 send_fake_signal(p); 131 fake_signal_wake_up(p);
139 } else { 132 } else {
140 if (with_mm_only) { 133 if (with_mm_only) {
141 ret = 0; 134 ret = 0;
@@ -182,15 +175,17 @@ static int try_to_freeze_tasks(int freeze_user_space)
182 if (frozen(p) || !freezeable(p)) 175 if (frozen(p) || !freezeable(p))
183 continue; 176 continue;
184 177
185 if (task_is_traced(p) && frozen(p->parent)) {
186 cancel_freezing(p);
187 continue;
188 }
189
190 if (!freeze_task(p, freeze_user_space)) 178 if (!freeze_task(p, freeze_user_space))
191 continue; 179 continue;
192 180
193 if (!freezer_should_skip(p)) 181 /*
182 * Now that we've done set_freeze_flag, don't
183 * perturb a task in TASK_STOPPED or TASK_TRACED.
184 * It is "frozen enough". If the task does wake
185 * up, it will immediately call try_to_freeze.
186 */
187 if (!task_is_stopped_or_traced(p) &&
188 !freezer_should_skip(p))
194 todo++; 189 todo++;
195 } while_each_thread(g, p); 190 } while_each_thread(g, p);
196 read_unlock(&tasklist_lock); 191 read_unlock(&tasklist_lock);
diff --git a/kernel/signal.c b/kernel/signal.c
index 84917fe507f7..6af1210092c3 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1623,7 +1623,6 @@ static void ptrace_stop(int exit_code, int clear_code, siginfo_t *info)
1623 /* Let the debugger run. */ 1623 /* Let the debugger run. */
1624 __set_current_state(TASK_TRACED); 1624 __set_current_state(TASK_TRACED);
1625 spin_unlock_irq(&current->sighand->siglock); 1625 spin_unlock_irq(&current->sighand->siglock);
1626 try_to_freeze();
1627 read_lock(&tasklist_lock); 1626 read_lock(&tasklist_lock);
1628 if (!unlikely(killed) && may_ptrace_stop()) { 1627 if (!unlikely(killed) && may_ptrace_stop()) {
1629 do_notify_parent_cldstop(current, CLD_TRAPPED); 1628 do_notify_parent_cldstop(current, CLD_TRAPPED);
@@ -1641,6 +1640,13 @@ static void ptrace_stop(int exit_code, int clear_code, siginfo_t *info)
1641 } 1640 }
1642 1641
1643 /* 1642 /*
1643 * While in TASK_TRACED, we were considered "frozen enough".
1644 * Now that we woke up, it's crucial if we're supposed to be
1645 * frozen that we freeze now before running anything substantial.
1646 */
1647 try_to_freeze();
1648
1649 /*
1644 * We are back. Now reacquire the siglock before touching 1650 * We are back. Now reacquire the siglock before touching
1645 * last_siginfo, so that we are sure to have synchronized with 1651 * last_siginfo, so that we are sure to have synchronized with
1646 * any signal-sending on another CPU that wants to examine it. 1652 * any signal-sending on another CPU that wants to examine it.
@@ -1757,9 +1763,15 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka,
1757 sigset_t *mask = &current->blocked; 1763 sigset_t *mask = &current->blocked;
1758 int signr = 0; 1764 int signr = 0;
1759 1765
1766relock:
1767 /*
1768 * We'll jump back here after any time we were stopped in TASK_STOPPED.
1769 * While in TASK_STOPPED, we were considered "frozen enough".
1770 * Now that we woke up, it's crucial if we're supposed to be
1771 * frozen that we freeze now before running anything substantial.
1772 */
1760 try_to_freeze(); 1773 try_to_freeze();
1761 1774
1762relock:
1763 spin_lock_irq(&current->sighand->siglock); 1775 spin_lock_irq(&current->sighand->siglock);
1764 for (;;) { 1776 for (;;) {
1765 struct k_sigaction *ka; 1777 struct k_sigaction *ka;
diff --git a/mm/slub.c b/mm/slub.c
index 74c65af0a54f..0863fd38a5ce 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -291,32 +291,16 @@ static inline struct kmem_cache_cpu *get_cpu_slab(struct kmem_cache *s, int cpu)
291#endif 291#endif
292} 292}
293 293
294/* 294/* Verify that a pointer has an address that is valid within a slab page */
295 * The end pointer in a slab is special. It points to the first object in the
296 * slab but has bit 0 set to mark it.
297 *
298 * Note that SLUB relies on page_mapping returning NULL for pages with bit 0
299 * in the mapping set.
300 */
301static inline int is_end(void *addr)
302{
303 return (unsigned long)addr & PAGE_MAPPING_ANON;
304}
305
306static void *slab_address(struct page *page)
307{
308 return page->end - PAGE_MAPPING_ANON;
309}
310
311static inline int check_valid_pointer(struct kmem_cache *s, 295static inline int check_valid_pointer(struct kmem_cache *s,
312 struct page *page, const void *object) 296 struct page *page, const void *object)
313{ 297{
314 void *base; 298 void *base;
315 299
316 if (object == page->end) 300 if (!object)
317 return 1; 301 return 1;
318 302
319 base = slab_address(page); 303 base = page_address(page);
320 if (object < base || object >= base + s->objects * s->size || 304 if (object < base || object >= base + s->objects * s->size ||
321 (object - base) % s->size) { 305 (object - base) % s->size) {
322 return 0; 306 return 0;
@@ -349,8 +333,7 @@ static inline void set_freepointer(struct kmem_cache *s, void *object, void *fp)
349 333
350/* Scan freelist */ 334/* Scan freelist */
351#define for_each_free_object(__p, __s, __free) \ 335#define for_each_free_object(__p, __s, __free) \
352 for (__p = (__free); (__p) != page->end; __p = get_freepointer((__s),\ 336 for (__p = (__free); __p; __p = get_freepointer((__s), __p))
353 __p))
354 337
355/* Determine object index from a given position */ 338/* Determine object index from a given position */
356static inline int slab_index(void *p, struct kmem_cache *s, void *addr) 339static inline int slab_index(void *p, struct kmem_cache *s, void *addr)
@@ -502,7 +485,7 @@ static void slab_fix(struct kmem_cache *s, char *fmt, ...)
502static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p) 485static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p)
503{ 486{
504 unsigned int off; /* Offset of last byte */ 487 unsigned int off; /* Offset of last byte */
505 u8 *addr = slab_address(page); 488 u8 *addr = page_address(page);
506 489
507 print_tracking(s, p); 490 print_tracking(s, p);
508 491
@@ -637,7 +620,7 @@ static int check_bytes_and_report(struct kmem_cache *s, struct page *page,
637 * A. Free pointer (if we cannot overwrite object on free) 620 * A. Free pointer (if we cannot overwrite object on free)
638 * B. Tracking data for SLAB_STORE_USER 621 * B. Tracking data for SLAB_STORE_USER
639 * C. Padding to reach required alignment boundary or at mininum 622 * C. Padding to reach required alignment boundary or at mininum
640 * one word if debuggin is on to be able to detect writes 623 * one word if debugging is on to be able to detect writes
641 * before the word boundary. 624 * before the word boundary.
642 * 625 *
643 * Padding is done using 0x5a (POISON_INUSE) 626 * Padding is done using 0x5a (POISON_INUSE)
@@ -680,7 +663,7 @@ static int slab_pad_check(struct kmem_cache *s, struct page *page)
680 if (!(s->flags & SLAB_POISON)) 663 if (!(s->flags & SLAB_POISON))
681 return 1; 664 return 1;
682 665
683 start = slab_address(page); 666 start = page_address(page);
684 end = start + (PAGE_SIZE << s->order); 667 end = start + (PAGE_SIZE << s->order);
685 length = s->objects * s->size; 668 length = s->objects * s->size;
686 remainder = end - (start + length); 669 remainder = end - (start + length);
@@ -748,7 +731,7 @@ static int check_object(struct kmem_cache *s, struct page *page,
748 * of the free objects in this slab. May cause 731 * of the free objects in this slab. May cause
749 * another error because the object count is now wrong. 732 * another error because the object count is now wrong.
750 */ 733 */
751 set_freepointer(s, p, page->end); 734 set_freepointer(s, p, NULL);
752 return 0; 735 return 0;
753 } 736 }
754 return 1; 737 return 1;
@@ -782,18 +765,18 @@ static int on_freelist(struct kmem_cache *s, struct page *page, void *search)
782 void *fp = page->freelist; 765 void *fp = page->freelist;
783 void *object = NULL; 766 void *object = NULL;
784 767
785 while (fp != page->end && nr <= s->objects) { 768 while (fp && nr <= s->objects) {
786 if (fp == search) 769 if (fp == search)
787 return 1; 770 return 1;
788 if (!check_valid_pointer(s, page, fp)) { 771 if (!check_valid_pointer(s, page, fp)) {
789 if (object) { 772 if (object) {
790 object_err(s, page, object, 773 object_err(s, page, object,
791 "Freechain corrupt"); 774 "Freechain corrupt");
792 set_freepointer(s, object, page->end); 775 set_freepointer(s, object, NULL);
793 break; 776 break;
794 } else { 777 } else {
795 slab_err(s, page, "Freepointer corrupt"); 778 slab_err(s, page, "Freepointer corrupt");
796 page->freelist = page->end; 779 page->freelist = NULL;
797 page->inuse = s->objects; 780 page->inuse = s->objects;
798 slab_fix(s, "Freelist cleared"); 781 slab_fix(s, "Freelist cleared");
799 return 0; 782 return 0;
@@ -870,7 +853,7 @@ static int alloc_debug_processing(struct kmem_cache *s, struct page *page,
870 if (!check_slab(s, page)) 853 if (!check_slab(s, page))
871 goto bad; 854 goto bad;
872 855
873 if (object && !on_freelist(s, page, object)) { 856 if (!on_freelist(s, page, object)) {
874 object_err(s, page, object, "Object already allocated"); 857 object_err(s, page, object, "Object already allocated");
875 goto bad; 858 goto bad;
876 } 859 }
@@ -880,7 +863,7 @@ static int alloc_debug_processing(struct kmem_cache *s, struct page *page,
880 goto bad; 863 goto bad;
881 } 864 }
882 865
883 if (object && !check_object(s, page, object, 0)) 866 if (!check_object(s, page, object, 0))
884 goto bad; 867 goto bad;
885 868
886 /* Success perform special debug activities for allocs */ 869 /* Success perform special debug activities for allocs */
@@ -899,7 +882,7 @@ bad:
899 */ 882 */
900 slab_fix(s, "Marking all objects used"); 883 slab_fix(s, "Marking all objects used");
901 page->inuse = s->objects; 884 page->inuse = s->objects;
902 page->freelist = page->end; 885 page->freelist = NULL;
903 } 886 }
904 return 0; 887 return 0;
905} 888}
@@ -939,7 +922,7 @@ static int free_debug_processing(struct kmem_cache *s, struct page *page,
939 } 922 }
940 923
941 /* Special debug activities for freeing objects */ 924 /* Special debug activities for freeing objects */
942 if (!SlabFrozen(page) && page->freelist == page->end) 925 if (!SlabFrozen(page) && !page->freelist)
943 remove_full(s, page); 926 remove_full(s, page);
944 if (s->flags & SLAB_STORE_USER) 927 if (s->flags & SLAB_STORE_USER)
945 set_track(s, object, TRACK_FREE, addr); 928 set_track(s, object, TRACK_FREE, addr);
@@ -1015,30 +998,11 @@ static unsigned long kmem_cache_flags(unsigned long objsize,
1015 void (*ctor)(struct kmem_cache *, void *)) 998 void (*ctor)(struct kmem_cache *, void *))
1016{ 999{
1017 /* 1000 /*
1018 * The page->offset field is only 16 bit wide. This is an offset 1001 * Enable debugging if selected on the kernel commandline.
1019 * in units of words from the beginning of an object. If the slab
1020 * size is bigger then we cannot move the free pointer behind the
1021 * object anymore.
1022 *
1023 * On 32 bit platforms the limit is 256k. On 64bit platforms
1024 * the limit is 512k.
1025 *
1026 * Debugging or ctor may create a need to move the free
1027 * pointer. Fail if this happens.
1028 */ 1002 */
1029 if (objsize >= 65535 * sizeof(void *)) { 1003 if (slub_debug && (!slub_debug_slabs ||
1030 BUG_ON(flags & (SLAB_RED_ZONE | SLAB_POISON | 1004 strncmp(slub_debug_slabs, name, strlen(slub_debug_slabs)) == 0))
1031 SLAB_STORE_USER | SLAB_DESTROY_BY_RCU)); 1005 flags |= slub_debug;
1032 BUG_ON(ctor);
1033 } else {
1034 /*
1035 * Enable debugging if selected on the kernel commandline.
1036 */
1037 if (slub_debug && (!slub_debug_slabs ||
1038 strncmp(slub_debug_slabs, name,
1039 strlen(slub_debug_slabs)) == 0))
1040 flags |= slub_debug;
1041 }
1042 1006
1043 return flags; 1007 return flags;
1044} 1008}
@@ -1124,7 +1088,6 @@ static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node)
1124 SetSlabDebug(page); 1088 SetSlabDebug(page);
1125 1089
1126 start = page_address(page); 1090 start = page_address(page);
1127 page->end = start + 1;
1128 1091
1129 if (unlikely(s->flags & SLAB_POISON)) 1092 if (unlikely(s->flags & SLAB_POISON))
1130 memset(start, POISON_INUSE, PAGE_SIZE << s->order); 1093 memset(start, POISON_INUSE, PAGE_SIZE << s->order);
@@ -1136,7 +1099,7 @@ static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node)
1136 last = p; 1099 last = p;
1137 } 1100 }
1138 setup_object(s, page, last); 1101 setup_object(s, page, last);
1139 set_freepointer(s, last, page->end); 1102 set_freepointer(s, last, NULL);
1140 1103
1141 page->freelist = start; 1104 page->freelist = start;
1142 page->inuse = 0; 1105 page->inuse = 0;
@@ -1152,7 +1115,7 @@ static void __free_slab(struct kmem_cache *s, struct page *page)
1152 void *p; 1115 void *p;
1153 1116
1154 slab_pad_check(s, page); 1117 slab_pad_check(s, page);
1155 for_each_object(p, s, slab_address(page)) 1118 for_each_object(p, s, page_address(page))
1156 check_object(s, page, p, 0); 1119 check_object(s, page, p, 0);
1157 ClearSlabDebug(page); 1120 ClearSlabDebug(page);
1158 } 1121 }
@@ -1162,7 +1125,6 @@ static void __free_slab(struct kmem_cache *s, struct page *page)
1162 NR_SLAB_RECLAIMABLE : NR_SLAB_UNRECLAIMABLE, 1125 NR_SLAB_RECLAIMABLE : NR_SLAB_UNRECLAIMABLE,
1163 -pages); 1126 -pages);
1164 1127
1165 page->mapping = NULL;
1166 __free_pages(page, s->order); 1128 __free_pages(page, s->order);
1167} 1129}
1168 1130
@@ -1307,7 +1269,7 @@ static struct page *get_any_partial(struct kmem_cache *s, gfp_t flags)
1307 * may return off node objects because partial slabs are obtained 1269 * may return off node objects because partial slabs are obtained
1308 * from other nodes and filled up. 1270 * from other nodes and filled up.
1309 * 1271 *
1310 * If /sys/slab/xx/defrag_ratio is set to 100 (which makes 1272 * If /sys/kernel/slab/xx/defrag_ratio is set to 100 (which makes
1311 * defrag_ratio = 1000) then every (well almost) allocation will 1273 * defrag_ratio = 1000) then every (well almost) allocation will
1312 * first attempt to defrag slab caches on other nodes. This means 1274 * first attempt to defrag slab caches on other nodes. This means
1313 * scanning over all nodes to look for partial slabs which may be 1275 * scanning over all nodes to look for partial slabs which may be
@@ -1366,7 +1328,7 @@ static void unfreeze_slab(struct kmem_cache *s, struct page *page, int tail)
1366 ClearSlabFrozen(page); 1328 ClearSlabFrozen(page);
1367 if (page->inuse) { 1329 if (page->inuse) {
1368 1330
1369 if (page->freelist != page->end) { 1331 if (page->freelist) {
1370 add_partial(n, page, tail); 1332 add_partial(n, page, tail);
1371 stat(c, tail ? DEACTIVATE_TO_TAIL : DEACTIVATE_TO_HEAD); 1333 stat(c, tail ? DEACTIVATE_TO_TAIL : DEACTIVATE_TO_HEAD);
1372 } else { 1334 } else {
@@ -1382,9 +1344,11 @@ static void unfreeze_slab(struct kmem_cache *s, struct page *page, int tail)
1382 * Adding an empty slab to the partial slabs in order 1344 * Adding an empty slab to the partial slabs in order
1383 * to avoid page allocator overhead. This slab needs 1345 * to avoid page allocator overhead. This slab needs
1384 * to come after the other slabs with objects in 1346 * to come after the other slabs with objects in
1385 * order to fill them up. That way the size of the 1347 * so that the others get filled first. That way the
1386 * partial list stays small. kmem_cache_shrink can 1348 * size of the partial list stays small.
1387 * reclaim empty slabs from the partial list. 1349 *
1350 * kmem_cache_shrink can reclaim any empty slabs from the
1351 * partial list.
1388 */ 1352 */
1389 add_partial(n, page, 1); 1353 add_partial(n, page, 1);
1390 slab_unlock(page); 1354 slab_unlock(page);
@@ -1407,15 +1371,11 @@ static void deactivate_slab(struct kmem_cache *s, struct kmem_cache_cpu *c)
1407 if (c->freelist) 1371 if (c->freelist)
1408 stat(c, DEACTIVATE_REMOTE_FREES); 1372 stat(c, DEACTIVATE_REMOTE_FREES);
1409 /* 1373 /*
1410 * Merge cpu freelist into freelist. Typically we get here 1374 * Merge cpu freelist into slab freelist. Typically we get here
1411 * because both freelists are empty. So this is unlikely 1375 * because both freelists are empty. So this is unlikely
1412 * to occur. 1376 * to occur.
1413 *
1414 * We need to use _is_end here because deactivate slab may
1415 * be called for a debug slab. Then c->freelist may contain
1416 * a dummy pointer.
1417 */ 1377 */
1418 while (unlikely(!is_end(c->freelist))) { 1378 while (unlikely(c->freelist)) {
1419 void **object; 1379 void **object;
1420 1380
1421 tail = 0; /* Hot objects. Put the slab first */ 1381 tail = 0; /* Hot objects. Put the slab first */
@@ -1442,6 +1402,7 @@ static inline void flush_slab(struct kmem_cache *s, struct kmem_cache_cpu *c)
1442 1402
1443/* 1403/*
1444 * Flush cpu slab. 1404 * Flush cpu slab.
1405 *
1445 * Called from IPI handler with interrupts disabled. 1406 * Called from IPI handler with interrupts disabled.
1446 */ 1407 */
1447static inline void __flush_cpu_slab(struct kmem_cache *s, int cpu) 1408static inline void __flush_cpu_slab(struct kmem_cache *s, int cpu)
@@ -1500,7 +1461,8 @@ static inline int node_match(struct kmem_cache_cpu *c, int node)
1500 * rest of the freelist to the lockless freelist. 1461 * rest of the freelist to the lockless freelist.
1501 * 1462 *
1502 * And if we were unable to get a new slab from the partial slab lists then 1463 * And if we were unable to get a new slab from the partial slab lists then
1503 * we need to allocate a new slab. This is slowest path since we may sleep. 1464 * we need to allocate a new slab. This is the slowest path since it involves
1465 * a call to the page allocator and the setup of a new slab.
1504 */ 1466 */
1505static void *__slab_alloc(struct kmem_cache *s, 1467static void *__slab_alloc(struct kmem_cache *s,
1506 gfp_t gfpflags, int node, void *addr, struct kmem_cache_cpu *c) 1468 gfp_t gfpflags, int node, void *addr, struct kmem_cache_cpu *c)
@@ -1514,18 +1476,19 @@ static void *__slab_alloc(struct kmem_cache *s,
1514 slab_lock(c->page); 1476 slab_lock(c->page);
1515 if (unlikely(!node_match(c, node))) 1477 if (unlikely(!node_match(c, node)))
1516 goto another_slab; 1478 goto another_slab;
1479
1517 stat(c, ALLOC_REFILL); 1480 stat(c, ALLOC_REFILL);
1481
1518load_freelist: 1482load_freelist:
1519 object = c->page->freelist; 1483 object = c->page->freelist;
1520 if (unlikely(object == c->page->end)) 1484 if (unlikely(!object))
1521 goto another_slab; 1485 goto another_slab;
1522 if (unlikely(SlabDebug(c->page))) 1486 if (unlikely(SlabDebug(c->page)))
1523 goto debug; 1487 goto debug;
1524 1488
1525 object = c->page->freelist;
1526 c->freelist = object[c->offset]; 1489 c->freelist = object[c->offset];
1527 c->page->inuse = s->objects; 1490 c->page->inuse = s->objects;
1528 c->page->freelist = c->page->end; 1491 c->page->freelist = NULL;
1529 c->node = page_to_nid(c->page); 1492 c->node = page_to_nid(c->page);
1530unlock_out: 1493unlock_out:
1531 slab_unlock(c->page); 1494 slab_unlock(c->page);
@@ -1578,7 +1541,6 @@ new_slab:
1578 1541
1579 return NULL; 1542 return NULL;
1580debug: 1543debug:
1581 object = c->page->freelist;
1582 if (!alloc_debug_processing(s, c->page, object, addr)) 1544 if (!alloc_debug_processing(s, c->page, object, addr))
1583 goto another_slab; 1545 goto another_slab;
1584 1546
@@ -1607,7 +1569,7 @@ static __always_inline void *slab_alloc(struct kmem_cache *s,
1607 1569
1608 local_irq_save(flags); 1570 local_irq_save(flags);
1609 c = get_cpu_slab(s, smp_processor_id()); 1571 c = get_cpu_slab(s, smp_processor_id());
1610 if (unlikely(is_end(c->freelist) || !node_match(c, node))) 1572 if (unlikely(!c->freelist || !node_match(c, node)))
1611 1573
1612 object = __slab_alloc(s, gfpflags, node, addr, c); 1574 object = __slab_alloc(s, gfpflags, node, addr, c);
1613 1575
@@ -1659,6 +1621,7 @@ static void __slab_free(struct kmem_cache *s, struct page *page,
1659 1621
1660 if (unlikely(SlabDebug(page))) 1622 if (unlikely(SlabDebug(page)))
1661 goto debug; 1623 goto debug;
1624
1662checks_ok: 1625checks_ok:
1663 prior = object[offset] = page->freelist; 1626 prior = object[offset] = page->freelist;
1664 page->freelist = object; 1627 page->freelist = object;
@@ -1673,11 +1636,10 @@ checks_ok:
1673 goto slab_empty; 1636 goto slab_empty;
1674 1637
1675 /* 1638 /*
1676 * Objects left in the slab. If it 1639 * Objects left in the slab. If it was not on the partial list before
1677 * was not on the partial list before
1678 * then add it. 1640 * then add it.
1679 */ 1641 */
1680 if (unlikely(prior == page->end)) { 1642 if (unlikely(!prior)) {
1681 add_partial(get_node(s, page_to_nid(page)), page, 1); 1643 add_partial(get_node(s, page_to_nid(page)), page, 1);
1682 stat(c, FREE_ADD_PARTIAL); 1644 stat(c, FREE_ADD_PARTIAL);
1683 } 1645 }
@@ -1687,7 +1649,7 @@ out_unlock:
1687 return; 1649 return;
1688 1650
1689slab_empty: 1651slab_empty:
1690 if (prior != page->end) { 1652 if (prior) {
1691 /* 1653 /*
1692 * Slab still on the partial list. 1654 * Slab still on the partial list.
1693 */ 1655 */
@@ -1724,8 +1686,8 @@ static __always_inline void slab_free(struct kmem_cache *s,
1724 unsigned long flags; 1686 unsigned long flags;
1725 1687
1726 local_irq_save(flags); 1688 local_irq_save(flags);
1727 debug_check_no_locks_freed(object, s->objsize);
1728 c = get_cpu_slab(s, smp_processor_id()); 1689 c = get_cpu_slab(s, smp_processor_id());
1690 debug_check_no_locks_freed(object, c->objsize);
1729 if (likely(page == c->page && c->node >= 0)) { 1691 if (likely(page == c->page && c->node >= 0)) {
1730 object[c->offset] = c->freelist; 1692 object[c->offset] = c->freelist;
1731 c->freelist = object; 1693 c->freelist = object;
@@ -1888,13 +1850,11 @@ static unsigned long calculate_alignment(unsigned long flags,
1888 unsigned long align, unsigned long size) 1850 unsigned long align, unsigned long size)
1889{ 1851{
1890 /* 1852 /*
1891 * If the user wants hardware cache aligned objects then 1853 * If the user wants hardware cache aligned objects then follow that
1892 * follow that suggestion if the object is sufficiently 1854 * suggestion if the object is sufficiently large.
1893 * large.
1894 * 1855 *
1895 * The hardware cache alignment cannot override the 1856 * The hardware cache alignment cannot override the specified
1896 * specified alignment though. If that is greater 1857 * alignment though. If that is greater then use it.
1897 * then use it.
1898 */ 1858 */
1899 if ((flags & SLAB_HWCACHE_ALIGN) && 1859 if ((flags & SLAB_HWCACHE_ALIGN) &&
1900 size > cache_line_size() / 2) 1860 size > cache_line_size() / 2)
@@ -1910,7 +1870,7 @@ static void init_kmem_cache_cpu(struct kmem_cache *s,
1910 struct kmem_cache_cpu *c) 1870 struct kmem_cache_cpu *c)
1911{ 1871{
1912 c->page = NULL; 1872 c->page = NULL;
1913 c->freelist = (void *)PAGE_MAPPING_ANON; 1873 c->freelist = NULL;
1914 c->node = 0; 1874 c->node = 0;
1915 c->offset = s->offset / sizeof(void *); 1875 c->offset = s->offset / sizeof(void *);
1916 c->objsize = s->objsize; 1876 c->objsize = s->objsize;
@@ -2092,6 +2052,7 @@ static struct kmem_cache_node *early_kmem_cache_node_alloc(gfp_t gfpflags,
2092#endif 2052#endif
2093 init_kmem_cache_node(n); 2053 init_kmem_cache_node(n);
2094 atomic_long_inc(&n->nr_slabs); 2054 atomic_long_inc(&n->nr_slabs);
2055
2095 /* 2056 /*
2096 * lockdep requires consistent irq usage for each lock 2057 * lockdep requires consistent irq usage for each lock
2097 * so even though there cannot be a race this early in 2058 * so even though there cannot be a race this early in
@@ -2173,6 +2134,14 @@ static int calculate_sizes(struct kmem_cache *s)
2173 unsigned long align = s->align; 2134 unsigned long align = s->align;
2174 2135
2175 /* 2136 /*
2137 * Round up object size to the next word boundary. We can only
2138 * place the free pointer at word boundaries and this determines
2139 * the possible location of the free pointer.
2140 */
2141 size = ALIGN(size, sizeof(void *));
2142
2143#ifdef CONFIG_SLUB_DEBUG
2144 /*
2176 * Determine if we can poison the object itself. If the user of 2145 * Determine if we can poison the object itself. If the user of
2177 * the slab may touch the object after free or before allocation 2146 * the slab may touch the object after free or before allocation
2178 * then we should never poison the object itself. 2147 * then we should never poison the object itself.
@@ -2183,14 +2152,7 @@ static int calculate_sizes(struct kmem_cache *s)
2183 else 2152 else
2184 s->flags &= ~__OBJECT_POISON; 2153 s->flags &= ~__OBJECT_POISON;
2185 2154
2186 /*
2187 * Round up object size to the next word boundary. We can only
2188 * place the free pointer at word boundaries and this determines
2189 * the possible location of the free pointer.
2190 */
2191 size = ALIGN(size, sizeof(void *));
2192 2155
2193#ifdef CONFIG_SLUB_DEBUG
2194 /* 2156 /*
2195 * If we are Redzoning then check if there is some space between the 2157 * If we are Redzoning then check if there is some space between the
2196 * end of the object and the free pointer. If not then add an 2158 * end of the object and the free pointer. If not then add an
@@ -2343,7 +2305,7 @@ int kmem_ptr_validate(struct kmem_cache *s, const void *object)
2343 /* 2305 /*
2344 * We could also check if the object is on the slabs freelist. 2306 * We could also check if the object is on the slabs freelist.
2345 * But this would be too expensive and it seems that the main 2307 * But this would be too expensive and it seems that the main
2346 * purpose of kmem_ptr_valid is to check if the object belongs 2308 * purpose of kmem_ptr_valid() is to check if the object belongs
2347 * to a certain slab. 2309 * to a certain slab.
2348 */ 2310 */
2349 return 1; 2311 return 1;
@@ -2630,13 +2592,24 @@ void *__kmalloc(size_t size, gfp_t flags)
2630} 2592}
2631EXPORT_SYMBOL(__kmalloc); 2593EXPORT_SYMBOL(__kmalloc);
2632 2594
2595static void *kmalloc_large_node(size_t size, gfp_t flags, int node)
2596{
2597 struct page *page = alloc_pages_node(node, flags | __GFP_COMP,
2598 get_order(size));
2599
2600 if (page)
2601 return page_address(page);
2602 else
2603 return NULL;
2604}
2605
2633#ifdef CONFIG_NUMA 2606#ifdef CONFIG_NUMA
2634void *__kmalloc_node(size_t size, gfp_t flags, int node) 2607void *__kmalloc_node(size_t size, gfp_t flags, int node)
2635{ 2608{
2636 struct kmem_cache *s; 2609 struct kmem_cache *s;
2637 2610
2638 if (unlikely(size > PAGE_SIZE)) 2611 if (unlikely(size > PAGE_SIZE))
2639 return kmalloc_large(size, flags); 2612 return kmalloc_large_node(size, flags, node);
2640 2613
2641 s = get_slab(size, flags); 2614 s = get_slab(size, flags);
2642 2615
@@ -2653,19 +2626,17 @@ size_t ksize(const void *object)
2653 struct page *page; 2626 struct page *page;
2654 struct kmem_cache *s; 2627 struct kmem_cache *s;
2655 2628
2656 BUG_ON(!object);
2657 if (unlikely(object == ZERO_SIZE_PTR)) 2629 if (unlikely(object == ZERO_SIZE_PTR))
2658 return 0; 2630 return 0;
2659 2631
2660 page = virt_to_head_page(object); 2632 page = virt_to_head_page(object);
2661 BUG_ON(!page);
2662 2633
2663 if (unlikely(!PageSlab(page))) 2634 if (unlikely(!PageSlab(page)))
2664 return PAGE_SIZE << compound_order(page); 2635 return PAGE_SIZE << compound_order(page);
2665 2636
2666 s = page->slab; 2637 s = page->slab;
2667 BUG_ON(!s);
2668 2638
2639#ifdef CONFIG_SLUB_DEBUG
2669 /* 2640 /*
2670 * Debugging requires use of the padding between object 2641 * Debugging requires use of the padding between object
2671 * and whatever may come after it. 2642 * and whatever may come after it.
@@ -2673,6 +2644,7 @@ size_t ksize(const void *object)
2673 if (s->flags & (SLAB_RED_ZONE | SLAB_POISON)) 2644 if (s->flags & (SLAB_RED_ZONE | SLAB_POISON))
2674 return s->objsize; 2645 return s->objsize;
2675 2646
2647#endif
2676 /* 2648 /*
2677 * If we have the need to store the freelist pointer 2649 * If we have the need to store the freelist pointer
2678 * back there or track user information then we can 2650 * back there or track user information then we can
@@ -2680,7 +2652,6 @@ size_t ksize(const void *object)
2680 */ 2652 */
2681 if (s->flags & (SLAB_DESTROY_BY_RCU | SLAB_STORE_USER)) 2653 if (s->flags & (SLAB_DESTROY_BY_RCU | SLAB_STORE_USER))
2682 return s->inuse; 2654 return s->inuse;
2683
2684 /* 2655 /*
2685 * Else we can use all the padding etc for the allocation 2656 * Else we can use all the padding etc for the allocation
2686 */ 2657 */
@@ -2957,7 +2928,7 @@ void __init kmem_cache_init(void)
2957 /* 2928 /*
2958 * Patch up the size_index table if we have strange large alignment 2929 * Patch up the size_index table if we have strange large alignment
2959 * requirements for the kmalloc array. This is only the case for 2930 * requirements for the kmalloc array. This is only the case for
2960 * mips it seems. The standard arches will not generate any code here. 2931 * MIPS it seems. The standard arches will not generate any code here.
2961 * 2932 *
2962 * Largest permitted alignment is 256 bytes due to the way we 2933 * Largest permitted alignment is 256 bytes due to the way we
2963 * handle the index determination for the smaller caches. 2934 * handle the index determination for the smaller caches.
@@ -2986,7 +2957,6 @@ void __init kmem_cache_init(void)
2986 kmem_size = sizeof(struct kmem_cache); 2957 kmem_size = sizeof(struct kmem_cache);
2987#endif 2958#endif
2988 2959
2989
2990 printk(KERN_INFO 2960 printk(KERN_INFO
2991 "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d," 2961 "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d,"
2992 " CPUs=%d, Nodes=%d\n", 2962 " CPUs=%d, Nodes=%d\n",
@@ -3083,12 +3053,15 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
3083 */ 3053 */
3084 for_each_online_cpu(cpu) 3054 for_each_online_cpu(cpu)
3085 get_cpu_slab(s, cpu)->objsize = s->objsize; 3055 get_cpu_slab(s, cpu)->objsize = s->objsize;
3056
3086 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *))); 3057 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
3087 up_write(&slub_lock); 3058 up_write(&slub_lock);
3059
3088 if (sysfs_slab_alias(s, name)) 3060 if (sysfs_slab_alias(s, name))
3089 goto err; 3061 goto err;
3090 return s; 3062 return s;
3091 } 3063 }
3064
3092 s = kmalloc(kmem_size, GFP_KERNEL); 3065 s = kmalloc(kmem_size, GFP_KERNEL);
3093 if (s) { 3066 if (s) {
3094 if (kmem_cache_open(s, GFP_KERNEL, name, 3067 if (kmem_cache_open(s, GFP_KERNEL, name,
@@ -3184,7 +3157,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
3184 struct kmem_cache *s; 3157 struct kmem_cache *s;
3185 3158
3186 if (unlikely(size > PAGE_SIZE)) 3159 if (unlikely(size > PAGE_SIZE))
3187 return kmalloc_large(size, gfpflags); 3160 return kmalloc_large_node(size, gfpflags, node);
3188 3161
3189 s = get_slab(size, gfpflags); 3162 s = get_slab(size, gfpflags);
3190 3163
@@ -3199,7 +3172,7 @@ static int validate_slab(struct kmem_cache *s, struct page *page,
3199 unsigned long *map) 3172 unsigned long *map)
3200{ 3173{
3201 void *p; 3174 void *p;
3202 void *addr = slab_address(page); 3175 void *addr = page_address(page);
3203 3176
3204 if (!check_slab(s, page) || 3177 if (!check_slab(s, page) ||
3205 !on_freelist(s, page, NULL)) 3178 !on_freelist(s, page, NULL))
@@ -3482,7 +3455,7 @@ static int add_location(struct loc_track *t, struct kmem_cache *s,
3482static void process_slab(struct loc_track *t, struct kmem_cache *s, 3455static void process_slab(struct loc_track *t, struct kmem_cache *s,
3483 struct page *page, enum track_item alloc) 3456 struct page *page, enum track_item alloc)
3484{ 3457{
3485 void *addr = slab_address(page); 3458 void *addr = page_address(page);
3486 DECLARE_BITMAP(map, s->objects); 3459 DECLARE_BITMAP(map, s->objects);
3487 void *p; 3460 void *p;
3488 3461
@@ -3591,8 +3564,8 @@ enum slab_stat_type {
3591#define SO_CPU (1 << SL_CPU) 3564#define SO_CPU (1 << SL_CPU)
3592#define SO_OBJECTS (1 << SL_OBJECTS) 3565#define SO_OBJECTS (1 << SL_OBJECTS)
3593 3566
3594static unsigned long slab_objects(struct kmem_cache *s, 3567static ssize_t show_slab_objects(struct kmem_cache *s,
3595 char *buf, unsigned long flags) 3568 char *buf, unsigned long flags)
3596{ 3569{
3597 unsigned long total = 0; 3570 unsigned long total = 0;
3598 int cpu; 3571 int cpu;
@@ -3602,6 +3575,8 @@ static unsigned long slab_objects(struct kmem_cache *s,
3602 unsigned long *per_cpu; 3575 unsigned long *per_cpu;
3603 3576
3604 nodes = kzalloc(2 * sizeof(unsigned long) * nr_node_ids, GFP_KERNEL); 3577 nodes = kzalloc(2 * sizeof(unsigned long) * nr_node_ids, GFP_KERNEL);
3578 if (!nodes)
3579 return -ENOMEM;
3605 per_cpu = nodes + nr_node_ids; 3580 per_cpu = nodes + nr_node_ids;
3606 3581
3607 for_each_possible_cpu(cpu) { 3582 for_each_possible_cpu(cpu) {
@@ -3754,25 +3729,25 @@ SLAB_ATTR_RO(aliases);
3754 3729
3755static ssize_t slabs_show(struct kmem_cache *s, char *buf) 3730static ssize_t slabs_show(struct kmem_cache *s, char *buf)
3756{ 3731{
3757 return slab_objects(s, buf, SO_FULL|SO_PARTIAL|SO_CPU); 3732 return show_slab_objects(s, buf, SO_FULL|SO_PARTIAL|SO_CPU);
3758} 3733}
3759SLAB_ATTR_RO(slabs); 3734SLAB_ATTR_RO(slabs);
3760 3735
3761static ssize_t partial_show(struct kmem_cache *s, char *buf) 3736static ssize_t partial_show(struct kmem_cache *s, char *buf)
3762{ 3737{
3763 return slab_objects(s, buf, SO_PARTIAL); 3738 return show_slab_objects(s, buf, SO_PARTIAL);
3764} 3739}
3765SLAB_ATTR_RO(partial); 3740SLAB_ATTR_RO(partial);
3766 3741
3767static ssize_t cpu_slabs_show(struct kmem_cache *s, char *buf) 3742static ssize_t cpu_slabs_show(struct kmem_cache *s, char *buf)
3768{ 3743{
3769 return slab_objects(s, buf, SO_CPU); 3744 return show_slab_objects(s, buf, SO_CPU);
3770} 3745}
3771SLAB_ATTR_RO(cpu_slabs); 3746SLAB_ATTR_RO(cpu_slabs);
3772 3747
3773static ssize_t objects_show(struct kmem_cache *s, char *buf) 3748static ssize_t objects_show(struct kmem_cache *s, char *buf)
3774{ 3749{
3775 return slab_objects(s, buf, SO_FULL|SO_PARTIAL|SO_CPU|SO_OBJECTS); 3750 return show_slab_objects(s, buf, SO_FULL|SO_PARTIAL|SO_CPU|SO_OBJECTS);
3776} 3751}
3777SLAB_ATTR_RO(objects); 3752SLAB_ATTR_RO(objects);
3778 3753
@@ -3971,7 +3946,6 @@ SLAB_ATTR(remote_node_defrag_ratio);
3971#endif 3946#endif
3972 3947
3973#ifdef CONFIG_SLUB_STATS 3948#ifdef CONFIG_SLUB_STATS
3974
3975static int show_stat(struct kmem_cache *s, char *buf, enum stat_item si) 3949static int show_stat(struct kmem_cache *s, char *buf, enum stat_item si)
3976{ 3950{
3977 unsigned long sum = 0; 3951 unsigned long sum = 0;
@@ -4155,8 +4129,8 @@ static struct kset *slab_kset;
4155#define ID_STR_LENGTH 64 4129#define ID_STR_LENGTH 64
4156 4130
4157/* Create a unique string id for a slab cache: 4131/* Create a unique string id for a slab cache:
4158 * format 4132 *
4159 * :[flags-]size:[memory address of kmemcache] 4133 * Format :[flags-]size
4160 */ 4134 */
4161static char *create_unique_id(struct kmem_cache *s) 4135static char *create_unique_id(struct kmem_cache *s)
4162{ 4136{
diff --git a/mm/truncate.c b/mm/truncate.c
index c35c49e54fb6..7d20ce41ecf5 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -134,8 +134,7 @@ invalidate_complete_page(struct address_space *mapping, struct page *page)
134} 134}
135 135
136/** 136/**
137 * truncate_inode_pages - truncate range of pages specified by start and 137 * truncate_inode_pages - truncate range of pages specified by start & end byte offsets
138 * end byte offsets
139 * @mapping: mapping to truncate 138 * @mapping: mapping to truncate
140 * @lstart: offset from which to truncate 139 * @lstart: offset from which to truncate
141 * @lend: offset to which to truncate 140 * @lend: offset to which to truncate