aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/DocBook/kernel-api.tmpl2
-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/x86/Kconfig2
-rw-r--r--arch/x86/kernel/i387.c8
-rw-r--r--arch/x86/kvm/lapic.c4
-rw-r--r--arch/x86/kvm/mmu.c38
-rw-r--r--arch/x86/kvm/paging_tmpl.h20
-rw-r--r--arch/x86/kvm/svm.c26
-rw-r--r--arch/x86/kvm/vmx.c14
-rw-r--r--arch/x86/kvm/x86.c114
-rw-r--r--arch/x86/mm/numa_64.c8
-rw-r--r--arch/x86/xen/setup.c3
-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/ata/libata-scsi.c9
-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/net/fec.c8
-rw-r--r--drivers/s390/char/defkeymap.c2
-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/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/linux/blkdev.h4
-rw-r--r--include/linux/genhd.h5
-rw-r--r--include/linux/kvm.h4
-rw-r--r--include/linux/kvm_host.h1
-rw-r--r--kernel/power/process.c29
-rw-r--r--kernel/signal.c16
-rw-r--r--virt/kvm/ioapic.c8
-rw-r--r--virt/kvm/kvm_main.c5
73 files changed, 926 insertions, 951 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/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/x86/Kconfig b/arch/x86/Kconfig
index 4a88cf7695b4..53800b80a204 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -21,7 +21,7 @@ config X86
21 select HAVE_IDE 21 select HAVE_IDE
22 select HAVE_OPROFILE 22 select HAVE_OPROFILE
23 select HAVE_KPROBES 23 select HAVE_KPROBES
24 select HAVE_KVM 24 select HAVE_KVM if ((X86_32 && !X86_VOYAGER && !X86_VISWS && !X86_NUMAQ) || X86_64)
25 25
26 26
27config GENERIC_LOCKBREAK 27config GENERIC_LOCKBREAK
diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
index 763dfc407232..60fe80157569 100644
--- a/arch/x86/kernel/i387.c
+++ b/arch/x86/kernel/i387.c
@@ -132,7 +132,7 @@ int xfpregs_get(struct task_struct *target, const struct user_regset *regset,
132 if (!cpu_has_fxsr) 132 if (!cpu_has_fxsr)
133 return -ENODEV; 133 return -ENODEV;
134 134
135 unlazy_fpu(target); 135 init_fpu(target);
136 136
137 return user_regset_copyout(&pos, &count, &kbuf, &ubuf, 137 return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
138 &target->thread.i387.fxsave, 0, -1); 138 &target->thread.i387.fxsave, 0, -1);
@@ -147,7 +147,7 @@ int xfpregs_set(struct task_struct *target, const struct user_regset *regset,
147 if (!cpu_has_fxsr) 147 if (!cpu_has_fxsr)
148 return -ENODEV; 148 return -ENODEV;
149 149
150 unlazy_fpu(target); 150 init_fpu(target);
151 set_stopped_child_used_math(target); 151 set_stopped_child_used_math(target);
152 152
153 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, 153 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
@@ -307,7 +307,7 @@ int fpregs_get(struct task_struct *target, const struct user_regset *regset,
307 if (!HAVE_HWFP) 307 if (!HAVE_HWFP)
308 return fpregs_soft_get(target, regset, pos, count, kbuf, ubuf); 308 return fpregs_soft_get(target, regset, pos, count, kbuf, ubuf);
309 309
310 unlazy_fpu(target); 310 init_fpu(target);
311 311
312 if (!cpu_has_fxsr) 312 if (!cpu_has_fxsr)
313 return user_regset_copyout(&pos, &count, &kbuf, &ubuf, 313 return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
@@ -332,7 +332,7 @@ int fpregs_set(struct task_struct *target, const struct user_regset *regset,
332 if (!HAVE_HWFP) 332 if (!HAVE_HWFP)
333 return fpregs_soft_set(target, regset, pos, count, kbuf, ubuf); 333 return fpregs_soft_set(target, regset, pos, count, kbuf, ubuf);
334 334
335 unlazy_fpu(target); 335 init_fpu(target);
336 set_stopped_child_used_math(target); 336 set_stopped_child_used_math(target);
337 337
338 if (!cpu_has_fxsr) 338 if (!cpu_has_fxsr)
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 2cbee9479ce4..68a6b1511934 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -647,6 +647,10 @@ static void start_apic_timer(struct kvm_lapic *apic)
647 apic->timer.period = apic_get_reg(apic, APIC_TMICT) * 647 apic->timer.period = apic_get_reg(apic, APIC_TMICT) *
648 APIC_BUS_CYCLE_NS * apic->timer.divide_count; 648 APIC_BUS_CYCLE_NS * apic->timer.divide_count;
649 atomic_set(&apic->timer.pending, 0); 649 atomic_set(&apic->timer.pending, 0);
650
651 if (!apic->timer.period)
652 return;
653
650 hrtimer_start(&apic->timer.dev, 654 hrtimer_start(&apic->timer.dev,
651 ktime_add_ns(now, apic->timer.period), 655 ktime_add_ns(now, apic->timer.period),
652 HRTIMER_MODE_ABS); 656 HRTIMER_MODE_ABS);
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 8efdcdbebb03..d8172aabc660 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -681,8 +681,7 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu,
681 unsigned level, 681 unsigned level,
682 int metaphysical, 682 int metaphysical,
683 unsigned access, 683 unsigned access,
684 u64 *parent_pte, 684 u64 *parent_pte)
685 bool *new_page)
686{ 685{
687 union kvm_mmu_page_role role; 686 union kvm_mmu_page_role role;
688 unsigned index; 687 unsigned index;
@@ -722,8 +721,6 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu,
722 vcpu->arch.mmu.prefetch_page(vcpu, sp); 721 vcpu->arch.mmu.prefetch_page(vcpu, sp);
723 if (!metaphysical) 722 if (!metaphysical)
724 rmap_write_protect(vcpu->kvm, gfn); 723 rmap_write_protect(vcpu->kvm, gfn);
725 if (new_page)
726 *new_page = 1;
727 return sp; 724 return sp;
728} 725}
729 726
@@ -876,11 +873,18 @@ static void page_header_update_slot(struct kvm *kvm, void *pte, gfn_t gfn)
876 873
877struct page *gva_to_page(struct kvm_vcpu *vcpu, gva_t gva) 874struct page *gva_to_page(struct kvm_vcpu *vcpu, gva_t gva)
878{ 875{
876 struct page *page;
877
879 gpa_t gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, gva); 878 gpa_t gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, gva);
880 879
881 if (gpa == UNMAPPED_GVA) 880 if (gpa == UNMAPPED_GVA)
882 return NULL; 881 return NULL;
883 return gfn_to_page(vcpu->kvm, gpa >> PAGE_SHIFT); 882
883 down_read(&current->mm->mmap_sem);
884 page = gfn_to_page(vcpu->kvm, gpa >> PAGE_SHIFT);
885 up_read(&current->mm->mmap_sem);
886
887 return page;
884} 888}
885 889
886static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *shadow_pte, 890static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *shadow_pte,
@@ -999,8 +1003,7 @@ static int __nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, int write,
999 >> PAGE_SHIFT; 1003 >> PAGE_SHIFT;
1000 new_table = kvm_mmu_get_page(vcpu, pseudo_gfn, 1004 new_table = kvm_mmu_get_page(vcpu, pseudo_gfn,
1001 v, level - 1, 1005 v, level - 1,
1002 1, ACC_ALL, &table[index], 1006 1, ACC_ALL, &table[index]);
1003 NULL);
1004 if (!new_table) { 1007 if (!new_table) {
1005 pgprintk("nonpaging_map: ENOMEM\n"); 1008 pgprintk("nonpaging_map: ENOMEM\n");
1006 kvm_release_page_clean(page); 1009 kvm_release_page_clean(page);
@@ -1020,15 +1023,18 @@ static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, int write, gfn_t gfn)
1020 1023
1021 struct page *page; 1024 struct page *page;
1022 1025
1026 down_read(&vcpu->kvm->slots_lock);
1027
1023 down_read(&current->mm->mmap_sem); 1028 down_read(&current->mm->mmap_sem);
1024 page = gfn_to_page(vcpu->kvm, gfn); 1029 page = gfn_to_page(vcpu->kvm, gfn);
1030 up_read(&current->mm->mmap_sem);
1025 1031
1026 spin_lock(&vcpu->kvm->mmu_lock); 1032 spin_lock(&vcpu->kvm->mmu_lock);
1027 kvm_mmu_free_some_pages(vcpu); 1033 kvm_mmu_free_some_pages(vcpu);
1028 r = __nonpaging_map(vcpu, v, write, gfn, page); 1034 r = __nonpaging_map(vcpu, v, write, gfn, page);
1029 spin_unlock(&vcpu->kvm->mmu_lock); 1035 spin_unlock(&vcpu->kvm->mmu_lock);
1030 1036
1031 up_read(&current->mm->mmap_sem); 1037 up_read(&vcpu->kvm->slots_lock);
1032 1038
1033 return r; 1039 return r;
1034} 1040}
@@ -1090,7 +1096,7 @@ static void mmu_alloc_roots(struct kvm_vcpu *vcpu)
1090 1096
1091 ASSERT(!VALID_PAGE(root)); 1097 ASSERT(!VALID_PAGE(root));
1092 sp = kvm_mmu_get_page(vcpu, root_gfn, 0, 1098 sp = kvm_mmu_get_page(vcpu, root_gfn, 0,
1093 PT64_ROOT_LEVEL, 0, ACC_ALL, NULL, NULL); 1099 PT64_ROOT_LEVEL, 0, ACC_ALL, NULL);
1094 root = __pa(sp->spt); 1100 root = __pa(sp->spt);
1095 ++sp->root_count; 1101 ++sp->root_count;
1096 vcpu->arch.mmu.root_hpa = root; 1102 vcpu->arch.mmu.root_hpa = root;
@@ -1111,7 +1117,7 @@ static void mmu_alloc_roots(struct kvm_vcpu *vcpu)
1111 root_gfn = 0; 1117 root_gfn = 0;
1112 sp = kvm_mmu_get_page(vcpu, root_gfn, i << 30, 1118 sp = kvm_mmu_get_page(vcpu, root_gfn, i << 30,
1113 PT32_ROOT_LEVEL, !is_paging(vcpu), 1119 PT32_ROOT_LEVEL, !is_paging(vcpu),
1114 ACC_ALL, NULL, NULL); 1120 ACC_ALL, NULL);
1115 root = __pa(sp->spt); 1121 root = __pa(sp->spt);
1116 ++sp->root_count; 1122 ++sp->root_count;
1117 vcpu->arch.mmu.pae_root[i] = root | PT_PRESENT_MASK; 1123 vcpu->arch.mmu.pae_root[i] = root | PT_PRESENT_MASK;
@@ -1172,7 +1178,7 @@ void kvm_mmu_flush_tlb(struct kvm_vcpu *vcpu)
1172 1178
1173static void paging_new_cr3(struct kvm_vcpu *vcpu) 1179static void paging_new_cr3(struct kvm_vcpu *vcpu)
1174{ 1180{
1175 pgprintk("%s: cr3 %lx\n", __FUNCTION__, vcpu->cr3); 1181 pgprintk("%s: cr3 %lx\n", __FUNCTION__, vcpu->arch.cr3);
1176 mmu_free_roots(vcpu); 1182 mmu_free_roots(vcpu);
1177} 1183}
1178 1184
@@ -1362,6 +1368,7 @@ static void mmu_guess_page_from_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
1362 gfn_t gfn; 1368 gfn_t gfn;
1363 int r; 1369 int r;
1364 u64 gpte = 0; 1370 u64 gpte = 0;
1371 struct page *page;
1365 1372
1366 if (bytes != 4 && bytes != 8) 1373 if (bytes != 4 && bytes != 8)
1367 return; 1374 return;
@@ -1389,6 +1396,11 @@ static void mmu_guess_page_from_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
1389 if (!is_present_pte(gpte)) 1396 if (!is_present_pte(gpte))
1390 return; 1397 return;
1391 gfn = (gpte & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT; 1398 gfn = (gpte & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT;
1399
1400 down_read(&current->mm->mmap_sem);
1401 page = gfn_to_page(vcpu->kvm, gfn);
1402 up_read(&current->mm->mmap_sem);
1403
1392 vcpu->arch.update_pte.gfn = gfn; 1404 vcpu->arch.update_pte.gfn = gfn;
1393 vcpu->arch.update_pte.page = gfn_to_page(vcpu->kvm, gfn); 1405 vcpu->arch.update_pte.page = gfn_to_page(vcpu->kvm, gfn);
1394} 1406}
@@ -1496,9 +1508,9 @@ int kvm_mmu_unprotect_page_virt(struct kvm_vcpu *vcpu, gva_t gva)
1496 gpa_t gpa; 1508 gpa_t gpa;
1497 int r; 1509 int r;
1498 1510
1499 down_read(&current->mm->mmap_sem); 1511 down_read(&vcpu->kvm->slots_lock);
1500 gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, gva); 1512 gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, gva);
1501 up_read(&current->mm->mmap_sem); 1513 up_read(&vcpu->kvm->slots_lock);
1502 1514
1503 spin_lock(&vcpu->kvm->mmu_lock); 1515 spin_lock(&vcpu->kvm->mmu_lock);
1504 r = kvm_mmu_unprotect_page(vcpu->kvm, gpa >> PAGE_SHIFT); 1516 r = kvm_mmu_unprotect_page(vcpu->kvm, gpa >> PAGE_SHIFT);
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index 03ba8608fe0f..ecc0856268c4 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -91,7 +91,10 @@ static bool FNAME(cmpxchg_gpte)(struct kvm *kvm,
91 pt_element_t *table; 91 pt_element_t *table;
92 struct page *page; 92 struct page *page;
93 93
94 down_read(&current->mm->mmap_sem);
94 page = gfn_to_page(kvm, table_gfn); 95 page = gfn_to_page(kvm, table_gfn);
96 up_read(&current->mm->mmap_sem);
97
95 table = kmap_atomic(page, KM_USER0); 98 table = kmap_atomic(page, KM_USER0);
96 99
97 ret = CMPXCHG(&table[index], orig_pte, new_pte); 100 ret = CMPXCHG(&table[index], orig_pte, new_pte);
@@ -140,7 +143,7 @@ walk:
140 } 143 }
141#endif 144#endif
142 ASSERT((!is_long_mode(vcpu) && is_pae(vcpu)) || 145 ASSERT((!is_long_mode(vcpu) && is_pae(vcpu)) ||
143 (vcpu->cr3 & CR3_NONPAE_RESERVED_BITS) == 0); 146 (vcpu->arch.cr3 & CR3_NONPAE_RESERVED_BITS) == 0);
144 147
145 pt_access = ACC_ALL; 148 pt_access = ACC_ALL;
146 149
@@ -297,7 +300,6 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
297 u64 shadow_pte; 300 u64 shadow_pte;
298 int metaphysical; 301 int metaphysical;
299 gfn_t table_gfn; 302 gfn_t table_gfn;
300 bool new_page = 0;
301 303
302 shadow_ent = ((u64 *)__va(shadow_addr)) + index; 304 shadow_ent = ((u64 *)__va(shadow_addr)) + index;
303 if (level == PT_PAGE_TABLE_LEVEL) 305 if (level == PT_PAGE_TABLE_LEVEL)
@@ -319,8 +321,8 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
319 } 321 }
320 shadow_page = kvm_mmu_get_page(vcpu, table_gfn, addr, level-1, 322 shadow_page = kvm_mmu_get_page(vcpu, table_gfn, addr, level-1,
321 metaphysical, access, 323 metaphysical, access,
322 shadow_ent, &new_page); 324 shadow_ent);
323 if (new_page && !metaphysical) { 325 if (!metaphysical) {
324 int r; 326 int r;
325 pt_element_t curr_pte; 327 pt_element_t curr_pte;
326 r = kvm_read_guest_atomic(vcpu->kvm, 328 r = kvm_read_guest_atomic(vcpu->kvm,
@@ -378,7 +380,7 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr,
378 if (r) 380 if (r)
379 return r; 381 return r;
380 382
381 down_read(&current->mm->mmap_sem); 383 down_read(&vcpu->kvm->slots_lock);
382 /* 384 /*
383 * Look up the shadow pte for the faulting address. 385 * Look up the shadow pte for the faulting address.
384 */ 386 */
@@ -392,11 +394,13 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr,
392 pgprintk("%s: guest page fault\n", __FUNCTION__); 394 pgprintk("%s: guest page fault\n", __FUNCTION__);
393 inject_page_fault(vcpu, addr, walker.error_code); 395 inject_page_fault(vcpu, addr, walker.error_code);
394 vcpu->arch.last_pt_write_count = 0; /* reset fork detector */ 396 vcpu->arch.last_pt_write_count = 0; /* reset fork detector */
395 up_read(&current->mm->mmap_sem); 397 up_read(&vcpu->kvm->slots_lock);
396 return 0; 398 return 0;
397 } 399 }
398 400
401 down_read(&current->mm->mmap_sem);
399 page = gfn_to_page(vcpu->kvm, walker.gfn); 402 page = gfn_to_page(vcpu->kvm, walker.gfn);
403 up_read(&current->mm->mmap_sem);
400 404
401 spin_lock(&vcpu->kvm->mmu_lock); 405 spin_lock(&vcpu->kvm->mmu_lock);
402 kvm_mmu_free_some_pages(vcpu); 406 kvm_mmu_free_some_pages(vcpu);
@@ -413,14 +417,14 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr,
413 */ 417 */
414 if (shadow_pte && is_io_pte(*shadow_pte)) { 418 if (shadow_pte && is_io_pte(*shadow_pte)) {
415 spin_unlock(&vcpu->kvm->mmu_lock); 419 spin_unlock(&vcpu->kvm->mmu_lock);
416 up_read(&current->mm->mmap_sem); 420 up_read(&vcpu->kvm->slots_lock);
417 return 1; 421 return 1;
418 } 422 }
419 423
420 ++vcpu->stat.pf_fixed; 424 ++vcpu->stat.pf_fixed;
421 kvm_mmu_audit(vcpu, "post page fault (fixed)"); 425 kvm_mmu_audit(vcpu, "post page fault (fixed)");
422 spin_unlock(&vcpu->kvm->mmu_lock); 426 spin_unlock(&vcpu->kvm->mmu_lock);
423 up_read(&current->mm->mmap_sem); 427 up_read(&vcpu->kvm->slots_lock);
424 428
425 return write_pt; 429 return write_pt;
426} 430}
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index de755cb1431d..1a582f1090e8 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -792,6 +792,10 @@ static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
792 vcpu->arch.cr0 = cr0; 792 vcpu->arch.cr0 = cr0;
793 cr0 |= X86_CR0_PG | X86_CR0_WP; 793 cr0 |= X86_CR0_PG | X86_CR0_WP;
794 cr0 &= ~(X86_CR0_CD | X86_CR0_NW); 794 cr0 &= ~(X86_CR0_CD | X86_CR0_NW);
795 if (!vcpu->fpu_active) {
796 svm->vmcb->control.intercept_exceptions |= (1 << NM_VECTOR);
797 cr0 |= X86_CR0_TS;
798 }
795 svm->vmcb->save.cr0 = cr0; 799 svm->vmcb->save.cr0 = cr0;
796} 800}
797 801
@@ -1096,6 +1100,24 @@ static int svm_get_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 *data)
1096 case MSR_IA32_SYSENTER_ESP: 1100 case MSR_IA32_SYSENTER_ESP:
1097 *data = svm->vmcb->save.sysenter_esp; 1101 *data = svm->vmcb->save.sysenter_esp;
1098 break; 1102 break;
1103 /* Nobody will change the following 5 values in the VMCB so
1104 we can safely return them on rdmsr. They will always be 0
1105 until LBRV is implemented. */
1106 case MSR_IA32_DEBUGCTLMSR:
1107 *data = svm->vmcb->save.dbgctl;
1108 break;
1109 case MSR_IA32_LASTBRANCHFROMIP:
1110 *data = svm->vmcb->save.br_from;
1111 break;
1112 case MSR_IA32_LASTBRANCHTOIP:
1113 *data = svm->vmcb->save.br_to;
1114 break;
1115 case MSR_IA32_LASTINTFROMIP:
1116 *data = svm->vmcb->save.last_excp_from;
1117 break;
1118 case MSR_IA32_LASTINTTOIP:
1119 *data = svm->vmcb->save.last_excp_to;
1120 break;
1099 default: 1121 default:
1100 return kvm_get_msr_common(vcpu, ecx, data); 1122 return kvm_get_msr_common(vcpu, ecx, data);
1101 } 1123 }
@@ -1156,6 +1178,10 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 data)
1156 case MSR_IA32_SYSENTER_ESP: 1178 case MSR_IA32_SYSENTER_ESP:
1157 svm->vmcb->save.sysenter_esp = data; 1179 svm->vmcb->save.sysenter_esp = data;
1158 break; 1180 break;
1181 case MSR_IA32_DEBUGCTLMSR:
1182 pr_unimpl(vcpu, "%s: MSR_IA32_DEBUGCTLMSR 0x%llx, nop\n",
1183 __FUNCTION__, data);
1184 break;
1159 case MSR_K7_EVNTSEL0: 1185 case MSR_K7_EVNTSEL0:
1160 case MSR_K7_EVNTSEL1: 1186 case MSR_K7_EVNTSEL1:
1161 case MSR_K7_EVNTSEL2: 1187 case MSR_K7_EVNTSEL2:
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index ad36447e696e..94ea724638fd 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -638,6 +638,7 @@ static void setup_msrs(struct vcpu_vmx *vmx)
638{ 638{
639 int save_nmsrs; 639 int save_nmsrs;
640 640
641 vmx_load_host_state(vmx);
641 save_nmsrs = 0; 642 save_nmsrs = 0;
642#ifdef CONFIG_X86_64 643#ifdef CONFIG_X86_64
643 if (is_long_mode(&vmx->vcpu)) { 644 if (is_long_mode(&vmx->vcpu)) {
@@ -1477,7 +1478,7 @@ static int alloc_apic_access_page(struct kvm *kvm)
1477 struct kvm_userspace_memory_region kvm_userspace_mem; 1478 struct kvm_userspace_memory_region kvm_userspace_mem;
1478 int r = 0; 1479 int r = 0;
1479 1480
1480 down_write(&current->mm->mmap_sem); 1481 down_write(&kvm->slots_lock);
1481 if (kvm->arch.apic_access_page) 1482 if (kvm->arch.apic_access_page)
1482 goto out; 1483 goto out;
1483 kvm_userspace_mem.slot = APIC_ACCESS_PAGE_PRIVATE_MEMSLOT; 1484 kvm_userspace_mem.slot = APIC_ACCESS_PAGE_PRIVATE_MEMSLOT;
@@ -1487,9 +1488,12 @@ static int alloc_apic_access_page(struct kvm *kvm)
1487 r = __kvm_set_memory_region(kvm, &kvm_userspace_mem, 0); 1488 r = __kvm_set_memory_region(kvm, &kvm_userspace_mem, 0);
1488 if (r) 1489 if (r)
1489 goto out; 1490 goto out;
1491
1492 down_read(&current->mm->mmap_sem);
1490 kvm->arch.apic_access_page = gfn_to_page(kvm, 0xfee00); 1493 kvm->arch.apic_access_page = gfn_to_page(kvm, 0xfee00);
1494 up_read(&current->mm->mmap_sem);
1491out: 1495out:
1492 up_write(&current->mm->mmap_sem); 1496 up_write(&kvm->slots_lock);
1493 return r; 1497 return r;
1494} 1498}
1495 1499
@@ -1602,9 +1606,6 @@ static int vmx_vcpu_setup(struct vcpu_vmx *vmx)
1602 vmcs_writel(CR0_GUEST_HOST_MASK, ~0UL); 1606 vmcs_writel(CR0_GUEST_HOST_MASK, ~0UL);
1603 vmcs_writel(CR4_GUEST_HOST_MASK, KVM_GUEST_CR4_MASK); 1607 vmcs_writel(CR4_GUEST_HOST_MASK, KVM_GUEST_CR4_MASK);
1604 1608
1605 if (vm_need_virtualize_apic_accesses(vmx->vcpu.kvm))
1606 if (alloc_apic_access_page(vmx->vcpu.kvm) != 0)
1607 return -ENOMEM;
1608 1609
1609 return 0; 1610 return 0;
1610} 1611}
@@ -2534,6 +2535,9 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
2534 put_cpu(); 2535 put_cpu();
2535 if (err) 2536 if (err)
2536 goto free_vmcs; 2537 goto free_vmcs;
2538 if (vm_need_virtualize_apic_accesses(kvm))
2539 if (alloc_apic_access_page(kvm) != 0)
2540 goto free_vmcs;
2537 2541
2538 return &vmx->vcpu; 2542 return &vmx->vcpu;
2539 2543
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index cf5308148689..6b01552bd1f1 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -46,6 +46,9 @@
46#define VM_STAT(x) offsetof(struct kvm, stat.x), KVM_STAT_VM 46#define VM_STAT(x) offsetof(struct kvm, stat.x), KVM_STAT_VM
47#define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU 47#define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU
48 48
49static int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid,
50 struct kvm_cpuid_entry2 __user *entries);
51
49struct kvm_x86_ops *kvm_x86_ops; 52struct kvm_x86_ops *kvm_x86_ops;
50 53
51struct kvm_stats_debugfs_item debugfs_entries[] = { 54struct kvm_stats_debugfs_item debugfs_entries[] = {
@@ -181,7 +184,7 @@ int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3)
181 int ret; 184 int ret;
182 u64 pdpte[ARRAY_SIZE(vcpu->arch.pdptrs)]; 185 u64 pdpte[ARRAY_SIZE(vcpu->arch.pdptrs)];
183 186
184 down_read(&current->mm->mmap_sem); 187 down_read(&vcpu->kvm->slots_lock);
185 ret = kvm_read_guest_page(vcpu->kvm, pdpt_gfn, pdpte, 188 ret = kvm_read_guest_page(vcpu->kvm, pdpt_gfn, pdpte,
186 offset * sizeof(u64), sizeof(pdpte)); 189 offset * sizeof(u64), sizeof(pdpte));
187 if (ret < 0) { 190 if (ret < 0) {
@@ -198,7 +201,7 @@ int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3)
198 201
199 memcpy(vcpu->arch.pdptrs, pdpte, sizeof(vcpu->arch.pdptrs)); 202 memcpy(vcpu->arch.pdptrs, pdpte, sizeof(vcpu->arch.pdptrs));
200out: 203out:
201 up_read(&current->mm->mmap_sem); 204 up_read(&vcpu->kvm->slots_lock);
202 205
203 return ret; 206 return ret;
204} 207}
@@ -212,13 +215,13 @@ static bool pdptrs_changed(struct kvm_vcpu *vcpu)
212 if (is_long_mode(vcpu) || !is_pae(vcpu)) 215 if (is_long_mode(vcpu) || !is_pae(vcpu))
213 return false; 216 return false;
214 217
215 down_read(&current->mm->mmap_sem); 218 down_read(&vcpu->kvm->slots_lock);
216 r = kvm_read_guest(vcpu->kvm, vcpu->arch.cr3 & ~31u, pdpte, sizeof(pdpte)); 219 r = kvm_read_guest(vcpu->kvm, vcpu->arch.cr3 & ~31u, pdpte, sizeof(pdpte));
217 if (r < 0) 220 if (r < 0)
218 goto out; 221 goto out;
219 changed = memcmp(pdpte, vcpu->arch.pdptrs, sizeof(pdpte)) != 0; 222 changed = memcmp(pdpte, vcpu->arch.pdptrs, sizeof(pdpte)) != 0;
220out: 223out:
221 up_read(&current->mm->mmap_sem); 224 up_read(&vcpu->kvm->slots_lock);
222 225
223 return changed; 226 return changed;
224} 227}
@@ -356,7 +359,7 @@ void set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
356 */ 359 */
357 } 360 }
358 361
359 down_read(&current->mm->mmap_sem); 362 down_read(&vcpu->kvm->slots_lock);
360 /* 363 /*
361 * Does the new cr3 value map to physical memory? (Note, we 364 * Does the new cr3 value map to physical memory? (Note, we
362 * catch an invalid cr3 even in real-mode, because it would 365 * catch an invalid cr3 even in real-mode, because it would
@@ -372,7 +375,7 @@ void set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
372 vcpu->arch.cr3 = cr3; 375 vcpu->arch.cr3 = cr3;
373 vcpu->arch.mmu.new_cr3(vcpu); 376 vcpu->arch.mmu.new_cr3(vcpu);
374 } 377 }
375 up_read(&current->mm->mmap_sem); 378 up_read(&vcpu->kvm->slots_lock);
376} 379}
377EXPORT_SYMBOL_GPL(set_cr3); 380EXPORT_SYMBOL_GPL(set_cr3);
378 381
@@ -484,6 +487,10 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
484 pr_unimpl(vcpu, "%s: MSR_IA32_MCG_STATUS 0x%llx, nop\n", 487 pr_unimpl(vcpu, "%s: MSR_IA32_MCG_STATUS 0x%llx, nop\n",
485 __FUNCTION__, data); 488 __FUNCTION__, data);
486 break; 489 break;
490 case MSR_IA32_MCG_CTL:
491 pr_unimpl(vcpu, "%s: MSR_IA32_MCG_CTL 0x%llx, nop\n",
492 __FUNCTION__, data);
493 break;
487 case MSR_IA32_UCODE_REV: 494 case MSR_IA32_UCODE_REV:
488 case MSR_IA32_UCODE_WRITE: 495 case MSR_IA32_UCODE_WRITE:
489 case 0x200 ... 0x2ff: /* MTRRs */ 496 case 0x200 ... 0x2ff: /* MTRRs */
@@ -526,6 +533,7 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
526 case MSR_IA32_MC0_CTL: 533 case MSR_IA32_MC0_CTL:
527 case MSR_IA32_MCG_STATUS: 534 case MSR_IA32_MCG_STATUS:
528 case MSR_IA32_MCG_CAP: 535 case MSR_IA32_MCG_CAP:
536 case MSR_IA32_MCG_CTL:
529 case MSR_IA32_MC0_MISC: 537 case MSR_IA32_MC0_MISC:
530 case MSR_IA32_MC0_MISC+4: 538 case MSR_IA32_MC0_MISC+4:
531 case MSR_IA32_MC0_MISC+8: 539 case MSR_IA32_MC0_MISC+8:
@@ -727,6 +735,24 @@ long kvm_arch_dev_ioctl(struct file *filp,
727 r = 0; 735 r = 0;
728 break; 736 break;
729 } 737 }
738 case KVM_GET_SUPPORTED_CPUID: {
739 struct kvm_cpuid2 __user *cpuid_arg = argp;
740 struct kvm_cpuid2 cpuid;
741
742 r = -EFAULT;
743 if (copy_from_user(&cpuid, cpuid_arg, sizeof cpuid))
744 goto out;
745 r = kvm_dev_ioctl_get_supported_cpuid(&cpuid,
746 cpuid_arg->entries);
747 if (r)
748 goto out;
749
750 r = -EFAULT;
751 if (copy_to_user(cpuid_arg, &cpuid, sizeof cpuid))
752 goto out;
753 r = 0;
754 break;
755 }
730 default: 756 default:
731 r = -EINVAL; 757 r = -EINVAL;
732 } 758 }
@@ -974,8 +1000,7 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
974 put_cpu(); 1000 put_cpu();
975} 1001}
976 1002
977static int kvm_vm_ioctl_get_supported_cpuid(struct kvm *kvm, 1003static int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid,
978 struct kvm_cpuid2 *cpuid,
979 struct kvm_cpuid_entry2 __user *entries) 1004 struct kvm_cpuid_entry2 __user *entries)
980{ 1005{
981 struct kvm_cpuid_entry2 *cpuid_entries; 1006 struct kvm_cpuid_entry2 *cpuid_entries;
@@ -1207,12 +1232,12 @@ static int kvm_vm_ioctl_set_nr_mmu_pages(struct kvm *kvm,
1207 if (kvm_nr_mmu_pages < KVM_MIN_ALLOC_MMU_PAGES) 1232 if (kvm_nr_mmu_pages < KVM_MIN_ALLOC_MMU_PAGES)
1208 return -EINVAL; 1233 return -EINVAL;
1209 1234
1210 down_write(&current->mm->mmap_sem); 1235 down_write(&kvm->slots_lock);
1211 1236
1212 kvm_mmu_change_mmu_pages(kvm, kvm_nr_mmu_pages); 1237 kvm_mmu_change_mmu_pages(kvm, kvm_nr_mmu_pages);
1213 kvm->arch.n_requested_mmu_pages = kvm_nr_mmu_pages; 1238 kvm->arch.n_requested_mmu_pages = kvm_nr_mmu_pages;
1214 1239
1215 up_write(&current->mm->mmap_sem); 1240 up_write(&kvm->slots_lock);
1216 return 0; 1241 return 0;
1217} 1242}
1218 1243
@@ -1261,7 +1286,7 @@ static int kvm_vm_ioctl_set_memory_alias(struct kvm *kvm,
1261 < alias->target_phys_addr) 1286 < alias->target_phys_addr)
1262 goto out; 1287 goto out;
1263 1288
1264 down_write(&current->mm->mmap_sem); 1289 down_write(&kvm->slots_lock);
1265 1290
1266 p = &kvm->arch.aliases[alias->slot]; 1291 p = &kvm->arch.aliases[alias->slot];
1267 p->base_gfn = alias->guest_phys_addr >> PAGE_SHIFT; 1292 p->base_gfn = alias->guest_phys_addr >> PAGE_SHIFT;
@@ -1275,7 +1300,7 @@ static int kvm_vm_ioctl_set_memory_alias(struct kvm *kvm,
1275 1300
1276 kvm_mmu_zap_all(kvm); 1301 kvm_mmu_zap_all(kvm);
1277 1302
1278 up_write(&current->mm->mmap_sem); 1303 up_write(&kvm->slots_lock);
1279 1304
1280 return 0; 1305 return 0;
1281 1306
@@ -1351,7 +1376,7 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
1351 struct kvm_memory_slot *memslot; 1376 struct kvm_memory_slot *memslot;
1352 int is_dirty = 0; 1377 int is_dirty = 0;
1353 1378
1354 down_write(&current->mm->mmap_sem); 1379 down_write(&kvm->slots_lock);
1355 1380
1356 r = kvm_get_dirty_log(kvm, log, &is_dirty); 1381 r = kvm_get_dirty_log(kvm, log, &is_dirty);
1357 if (r) 1382 if (r)
@@ -1367,7 +1392,7 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
1367 } 1392 }
1368 r = 0; 1393 r = 0;
1369out: 1394out:
1370 up_write(&current->mm->mmap_sem); 1395 up_write(&kvm->slots_lock);
1371 return r; 1396 return r;
1372} 1397}
1373 1398
@@ -1487,24 +1512,6 @@ long kvm_arch_vm_ioctl(struct file *filp,
1487 r = 0; 1512 r = 0;
1488 break; 1513 break;
1489 } 1514 }
1490 case KVM_GET_SUPPORTED_CPUID: {
1491 struct kvm_cpuid2 __user *cpuid_arg = argp;
1492 struct kvm_cpuid2 cpuid;
1493
1494 r = -EFAULT;
1495 if (copy_from_user(&cpuid, cpuid_arg, sizeof cpuid))
1496 goto out;
1497 r = kvm_vm_ioctl_get_supported_cpuid(kvm, &cpuid,
1498 cpuid_arg->entries);
1499 if (r)
1500 goto out;
1501
1502 r = -EFAULT;
1503 if (copy_to_user(cpuid_arg, &cpuid, sizeof cpuid))
1504 goto out;
1505 r = 0;
1506 break;
1507 }
1508 default: 1515 default:
1509 ; 1516 ;
1510 } 1517 }
@@ -1563,7 +1570,7 @@ int emulator_read_std(unsigned long addr,
1563 void *data = val; 1570 void *data = val;
1564 int r = X86EMUL_CONTINUE; 1571 int r = X86EMUL_CONTINUE;
1565 1572
1566 down_read(&current->mm->mmap_sem); 1573 down_read(&vcpu->kvm->slots_lock);
1567 while (bytes) { 1574 while (bytes) {
1568 gpa_t gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, addr); 1575 gpa_t gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, addr);
1569 unsigned offset = addr & (PAGE_SIZE-1); 1576 unsigned offset = addr & (PAGE_SIZE-1);
@@ -1585,7 +1592,7 @@ int emulator_read_std(unsigned long addr,
1585 addr += tocopy; 1592 addr += tocopy;
1586 } 1593 }
1587out: 1594out:
1588 up_read(&current->mm->mmap_sem); 1595 up_read(&vcpu->kvm->slots_lock);
1589 return r; 1596 return r;
1590} 1597}
1591EXPORT_SYMBOL_GPL(emulator_read_std); 1598EXPORT_SYMBOL_GPL(emulator_read_std);
@@ -1604,9 +1611,9 @@ static int emulator_read_emulated(unsigned long addr,
1604 return X86EMUL_CONTINUE; 1611 return X86EMUL_CONTINUE;
1605 } 1612 }
1606 1613
1607 down_read(&current->mm->mmap_sem); 1614 down_read(&vcpu->kvm->slots_lock);
1608 gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, addr); 1615 gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, addr);
1609 up_read(&current->mm->mmap_sem); 1616 up_read(&vcpu->kvm->slots_lock);
1610 1617
1611 /* For APIC access vmexit */ 1618 /* For APIC access vmexit */
1612 if ((gpa & PAGE_MASK) == APIC_DEFAULT_PHYS_BASE) 1619 if ((gpa & PAGE_MASK) == APIC_DEFAULT_PHYS_BASE)
@@ -1644,14 +1651,14 @@ static int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa,
1644{ 1651{
1645 int ret; 1652 int ret;
1646 1653
1647 down_read(&current->mm->mmap_sem); 1654 down_read(&vcpu->kvm->slots_lock);
1648 ret = kvm_write_guest(vcpu->kvm, gpa, val, bytes); 1655 ret = kvm_write_guest(vcpu->kvm, gpa, val, bytes);
1649 if (ret < 0) { 1656 if (ret < 0) {
1650 up_read(&current->mm->mmap_sem); 1657 up_read(&vcpu->kvm->slots_lock);
1651 return 0; 1658 return 0;
1652 } 1659 }
1653 kvm_mmu_pte_write(vcpu, gpa, val, bytes); 1660 kvm_mmu_pte_write(vcpu, gpa, val, bytes);
1654 up_read(&current->mm->mmap_sem); 1661 up_read(&vcpu->kvm->slots_lock);
1655 return 1; 1662 return 1;
1656} 1663}
1657 1664
@@ -1663,9 +1670,9 @@ static int emulator_write_emulated_onepage(unsigned long addr,
1663 struct kvm_io_device *mmio_dev; 1670 struct kvm_io_device *mmio_dev;
1664 gpa_t gpa; 1671 gpa_t gpa;
1665 1672
1666 down_read(&current->mm->mmap_sem); 1673 down_read(&vcpu->kvm->slots_lock);
1667 gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, addr); 1674 gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, addr);
1668 up_read(&current->mm->mmap_sem); 1675 up_read(&vcpu->kvm->slots_lock);
1669 1676
1670 if (gpa == UNMAPPED_GVA) { 1677 if (gpa == UNMAPPED_GVA) {
1671 kvm_inject_page_fault(vcpu, addr, 2); 1678 kvm_inject_page_fault(vcpu, addr, 2);
@@ -1742,7 +1749,7 @@ static int emulator_cmpxchg_emulated(unsigned long addr,
1742 char *kaddr; 1749 char *kaddr;
1743 u64 val; 1750 u64 val;
1744 1751
1745 down_read(&current->mm->mmap_sem); 1752 down_read(&vcpu->kvm->slots_lock);
1746 gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, addr); 1753 gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, addr);
1747 1754
1748 if (gpa == UNMAPPED_GVA || 1755 if (gpa == UNMAPPED_GVA ||
@@ -1753,13 +1760,17 @@ static int emulator_cmpxchg_emulated(unsigned long addr,
1753 goto emul_write; 1760 goto emul_write;
1754 1761
1755 val = *(u64 *)new; 1762 val = *(u64 *)new;
1763
1764 down_read(&current->mm->mmap_sem);
1756 page = gfn_to_page(vcpu->kvm, gpa >> PAGE_SHIFT); 1765 page = gfn_to_page(vcpu->kvm, gpa >> PAGE_SHIFT);
1766 up_read(&current->mm->mmap_sem);
1767
1757 kaddr = kmap_atomic(page, KM_USER0); 1768 kaddr = kmap_atomic(page, KM_USER0);
1758 set_64bit((u64 *)(kaddr + offset_in_page(gpa)), val); 1769 set_64bit((u64 *)(kaddr + offset_in_page(gpa)), val);
1759 kunmap_atomic(kaddr, KM_USER0); 1770 kunmap_atomic(kaddr, KM_USER0);
1760 kvm_release_page_dirty(page); 1771 kvm_release_page_dirty(page);
1761 emul_write: 1772 emul_write:
1762 up_read(&current->mm->mmap_sem); 1773 up_read(&vcpu->kvm->slots_lock);
1763 } 1774 }
1764#endif 1775#endif
1765 1776
@@ -2152,10 +2163,10 @@ int kvm_emulate_pio_string(struct kvm_vcpu *vcpu, struct kvm_run *run, int in,
2152 kvm_x86_ops->skip_emulated_instruction(vcpu); 2163 kvm_x86_ops->skip_emulated_instruction(vcpu);
2153 2164
2154 for (i = 0; i < nr_pages; ++i) { 2165 for (i = 0; i < nr_pages; ++i) {
2155 down_read(&current->mm->mmap_sem); 2166 down_read(&vcpu->kvm->slots_lock);
2156 page = gva_to_page(vcpu, address + i * PAGE_SIZE); 2167 page = gva_to_page(vcpu, address + i * PAGE_SIZE);
2157 vcpu->arch.pio.guest_pages[i] = page; 2168 vcpu->arch.pio.guest_pages[i] = page;
2158 up_read(&current->mm->mmap_sem); 2169 up_read(&vcpu->kvm->slots_lock);
2159 if (!page) { 2170 if (!page) {
2160 kvm_inject_gp(vcpu, 0); 2171 kvm_inject_gp(vcpu, 0);
2161 free_pio_guest_pages(vcpu); 2172 free_pio_guest_pages(vcpu);
@@ -2478,8 +2489,9 @@ static void vapic_enter(struct kvm_vcpu *vcpu)
2478 2489
2479 down_read(&current->mm->mmap_sem); 2490 down_read(&current->mm->mmap_sem);
2480 page = gfn_to_page(vcpu->kvm, apic->vapic_addr >> PAGE_SHIFT); 2491 page = gfn_to_page(vcpu->kvm, apic->vapic_addr >> PAGE_SHIFT);
2481 vcpu->arch.apic->vapic_page = page;
2482 up_read(&current->mm->mmap_sem); 2492 up_read(&current->mm->mmap_sem);
2493
2494 vcpu->arch.apic->vapic_page = page;
2483} 2495}
2484 2496
2485static void vapic_exit(struct kvm_vcpu *vcpu) 2497static void vapic_exit(struct kvm_vcpu *vcpu)
@@ -2861,8 +2873,8 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
2861 kvm_x86_ops->decache_cr4_guest_bits(vcpu); 2873 kvm_x86_ops->decache_cr4_guest_bits(vcpu);
2862 2874
2863 mmu_reset_needed |= vcpu->arch.cr0 != sregs->cr0; 2875 mmu_reset_needed |= vcpu->arch.cr0 != sregs->cr0;
2864 vcpu->arch.cr0 = sregs->cr0;
2865 kvm_x86_ops->set_cr0(vcpu, sregs->cr0); 2876 kvm_x86_ops->set_cr0(vcpu, sregs->cr0);
2877 vcpu->arch.cr0 = sregs->cr0;
2866 2878
2867 mmu_reset_needed |= vcpu->arch.cr4 != sregs->cr4; 2879 mmu_reset_needed |= vcpu->arch.cr4 != sregs->cr4;
2868 kvm_x86_ops->set_cr4(vcpu, sregs->cr4); 2880 kvm_x86_ops->set_cr4(vcpu, sregs->cr4);
@@ -2952,9 +2964,9 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu,
2952 gpa_t gpa; 2964 gpa_t gpa;
2953 2965
2954 vcpu_load(vcpu); 2966 vcpu_load(vcpu);
2955 down_read(&current->mm->mmap_sem); 2967 down_read(&vcpu->kvm->slots_lock);
2956 gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, vaddr); 2968 gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, vaddr);
2957 up_read(&current->mm->mmap_sem); 2969 up_read(&vcpu->kvm->slots_lock);
2958 tr->physical_address = gpa; 2970 tr->physical_address = gpa;
2959 tr->valid = gpa != UNMAPPED_GVA; 2971 tr->valid = gpa != UNMAPPED_GVA;
2960 tr->writeable = 1; 2972 tr->writeable = 1;
@@ -3227,11 +3239,13 @@ int kvm_arch_set_memory_region(struct kvm *kvm,
3227 */ 3239 */
3228 if (!user_alloc) { 3240 if (!user_alloc) {
3229 if (npages && !old.rmap) { 3241 if (npages && !old.rmap) {
3242 down_write(&current->mm->mmap_sem);
3230 memslot->userspace_addr = do_mmap(NULL, 0, 3243 memslot->userspace_addr = do_mmap(NULL, 0,
3231 npages * PAGE_SIZE, 3244 npages * PAGE_SIZE,
3232 PROT_READ | PROT_WRITE, 3245 PROT_READ | PROT_WRITE,
3233 MAP_SHARED | MAP_ANONYMOUS, 3246 MAP_SHARED | MAP_ANONYMOUS,
3234 0); 3247 0);
3248 up_write(&current->mm->mmap_sem);
3235 3249
3236 if (IS_ERR((void *)memslot->userspace_addr)) 3250 if (IS_ERR((void *)memslot->userspace_addr))
3237 return PTR_ERR((void *)memslot->userspace_addr); 3251 return PTR_ERR((void *)memslot->userspace_addr);
@@ -3239,8 +3253,10 @@ int kvm_arch_set_memory_region(struct kvm *kvm,
3239 if (!old.user_alloc && old.rmap) { 3253 if (!old.user_alloc && old.rmap) {
3240 int ret; 3254 int ret;
3241 3255
3256 down_write(&current->mm->mmap_sem);
3242 ret = do_munmap(current->mm, old.userspace_addr, 3257 ret = do_munmap(current->mm, old.userspace_addr,
3243 old.npages * PAGE_SIZE); 3258 old.npages * PAGE_SIZE);
3259 up_write(&current->mm->mmap_sem);
3244 if (ret < 0) 3260 if (ret < 0)
3245 printk(KERN_WARNING 3261 printk(KERN_WARNING
3246 "kvm_vm_ioctl_set_memory_region: " 3262 "kvm_vm_ioctl_set_memory_region: "
diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c
index 59898fb0a4aa..8ccfee10f5b5 100644
--- a/arch/x86/mm/numa_64.c
+++ b/arch/x86/mm/numa_64.c
@@ -622,13 +622,17 @@ void __init init_cpu_to_node(void)
622 int i; 622 int i;
623 623
624 for (i = 0; i < NR_CPUS; i++) { 624 for (i = 0; i < NR_CPUS; i++) {
625 int node;
625 u16 apicid = x86_cpu_to_apicid_init[i]; 626 u16 apicid = x86_cpu_to_apicid_init[i];
626 627
627 if (apicid == BAD_APICID) 628 if (apicid == BAD_APICID)
628 continue; 629 continue;
629 if (apicid_to_node[apicid] == NUMA_NO_NODE) 630 node = apicid_to_node[apicid];
631 if (node == NUMA_NO_NODE)
630 continue; 632 continue;
631 numa_set_node(i, apicid_to_node[apicid]); 633 if (!node_online(node))
634 continue;
635 numa_set_node(i, node);
632 } 636 }
633} 637}
634 638
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 3bad4773a2f3..2341492bf7a0 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -38,7 +38,8 @@ char * __init xen_memory_setup(void)
38 unsigned long max_pfn = xen_start_info->nr_pages; 38 unsigned long max_pfn = xen_start_info->nr_pages;
39 39
40 e820.nr_map = 0; 40 e820.nr_map = 0;
41 add_memory_region(0, PFN_PHYS(max_pfn), E820_RAM); 41 add_memory_region(0, LOWMEMSIZE(), E820_RAM);
42 add_memory_region(HIGH_MEMORY, PFN_PHYS(max_pfn)-HIGH_MEMORY, E820_RAM);
42 43
43 return "Xen"; 44 return "Xen";
44} 45}
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/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/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/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/s390/char/defkeymap.c b/drivers/s390/char/defkeymap.c
index 9692d6a205ef..07c7f31081bc 100644
--- a/drivers/s390/char/defkeymap.c
+++ b/drivers/s390/char/defkeymap.c
@@ -152,7 +152,7 @@ char *func_table[MAX_NR_FUNC] = {
152 152
153struct kbdiacruc accent_table[MAX_DIACR] = { 153struct kbdiacruc accent_table[MAX_DIACR] = {
154 {'^', 'c', 0003}, {'^', 'd', 0004}, 154 {'^', 'c', 0003}, {'^', 'd', 0004},
155 {'^', 'z', 0032}, {'^', 0012', 0000}, 155 {'^', 'z', 0032}, {'^', 0012, 0000},
156}; 156};
157 157
158unsigned int accent_table_size = 4; 158unsigned int accent_table_size = 4;
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/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/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/kvm.h b/include/linux/kvm.h
index 4de4fd2d8607..c1ec04fd000d 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -221,6 +221,7 @@ struct kvm_vapic_addr {
221 * Get size for mmap(vcpu_fd) 221 * Get size for mmap(vcpu_fd)
222 */ 222 */
223#define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04) /* in bytes */ 223#define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04) /* in bytes */
224#define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x05, struct kvm_cpuid2)
224 225
225/* 226/*
226 * Extension capability list. 227 * Extension capability list.
@@ -230,8 +231,8 @@ struct kvm_vapic_addr {
230#define KVM_CAP_MMU_SHADOW_CACHE_CONTROL 2 231#define KVM_CAP_MMU_SHADOW_CACHE_CONTROL 2
231#define KVM_CAP_USER_MEMORY 3 232#define KVM_CAP_USER_MEMORY 3
232#define KVM_CAP_SET_TSS_ADDR 4 233#define KVM_CAP_SET_TSS_ADDR 4
233#define KVM_CAP_EXT_CPUID 5
234#define KVM_CAP_VAPIC 6 234#define KVM_CAP_VAPIC 6
235#define KVM_CAP_EXT_CPUID 7
235 236
236/* 237/*
237 * ioctls for VM fds 238 * ioctls for VM fds
@@ -249,7 +250,6 @@ struct kvm_vapic_addr {
249#define KVM_CREATE_VCPU _IO(KVMIO, 0x41) 250#define KVM_CREATE_VCPU _IO(KVMIO, 0x41)
250#define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log) 251#define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log)
251#define KVM_SET_MEMORY_ALIAS _IOW(KVMIO, 0x43, struct kvm_memory_alias) 252#define KVM_SET_MEMORY_ALIAS _IOW(KVMIO, 0x43, struct kvm_memory_alias)
252#define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x48, struct kvm_cpuid2)
253/* Device model IOC */ 253/* Device model IOC */
254#define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60) 254#define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60)
255#define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level) 255#define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level)
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index ea4764b0a2f4..928b0d59e9ba 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -107,6 +107,7 @@ struct kvm_memory_slot {
107struct kvm { 107struct kvm {
108 struct mutex lock; /* protects the vcpus array and APIC accesses */ 108 struct mutex lock; /* protects the vcpus array and APIC accesses */
109 spinlock_t mmu_lock; 109 spinlock_t mmu_lock;
110 struct rw_semaphore slots_lock;
110 struct mm_struct *mm; /* userspace tied to this vm */ 111 struct mm_struct *mm; /* userspace tied to this vm */
111 int nmemslots; 112 int nmemslots;
112 struct kvm_memory_slot memslots[KVM_MEMORY_SLOTS + 113 struct kvm_memory_slot memslots[KVM_MEMORY_SLOTS +
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/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
index 317f8e211cd2..4232fd75dd20 100644
--- a/virt/kvm/ioapic.c
+++ b/virt/kvm/ioapic.c
@@ -211,6 +211,10 @@ static void ioapic_deliver(struct kvm_ioapic *ioapic, int irq)
211 case IOAPIC_LOWEST_PRIORITY: 211 case IOAPIC_LOWEST_PRIORITY:
212 vcpu = kvm_get_lowest_prio_vcpu(ioapic->kvm, vector, 212 vcpu = kvm_get_lowest_prio_vcpu(ioapic->kvm, vector,
213 deliver_bitmask); 213 deliver_bitmask);
214#ifdef CONFIG_X86
215 if (irq == 0)
216 vcpu = ioapic->kvm->vcpus[0];
217#endif
214 if (vcpu != NULL) 218 if (vcpu != NULL)
215 ioapic_inj_irq(ioapic, vcpu, vector, 219 ioapic_inj_irq(ioapic, vcpu, vector,
216 trig_mode, delivery_mode); 220 trig_mode, delivery_mode);
@@ -220,6 +224,10 @@ static void ioapic_deliver(struct kvm_ioapic *ioapic, int irq)
220 deliver_bitmask, vector, IOAPIC_LOWEST_PRIORITY); 224 deliver_bitmask, vector, IOAPIC_LOWEST_PRIORITY);
221 break; 225 break;
222 case IOAPIC_FIXED: 226 case IOAPIC_FIXED:
227#ifdef CONFIG_X86
228 if (irq == 0)
229 deliver_bitmask = 1;
230#endif
223 for (vcpu_id = 0; deliver_bitmask != 0; vcpu_id++) { 231 for (vcpu_id = 0; deliver_bitmask != 0; vcpu_id++) {
224 if (!(deliver_bitmask & (1 << vcpu_id))) 232 if (!(deliver_bitmask & (1 << vcpu_id)))
225 continue; 233 continue;
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 32fbf8006969..b2e12893e3f4 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -169,6 +169,7 @@ static struct kvm *kvm_create_vm(void)
169 kvm_io_bus_init(&kvm->pio_bus); 169 kvm_io_bus_init(&kvm->pio_bus);
170 mutex_init(&kvm->lock); 170 mutex_init(&kvm->lock);
171 kvm_io_bus_init(&kvm->mmio_bus); 171 kvm_io_bus_init(&kvm->mmio_bus);
172 init_rwsem(&kvm->slots_lock);
172 spin_lock(&kvm_lock); 173 spin_lock(&kvm_lock);
173 list_add(&kvm->vm_list, &vm_list); 174 list_add(&kvm->vm_list, &vm_list);
174 spin_unlock(&kvm_lock); 175 spin_unlock(&kvm_lock);
@@ -339,9 +340,9 @@ int kvm_set_memory_region(struct kvm *kvm,
339{ 340{
340 int r; 341 int r;
341 342
342 down_write(&current->mm->mmap_sem); 343 down_write(&kvm->slots_lock);
343 r = __kvm_set_memory_region(kvm, mem, user_alloc); 344 r = __kvm_set_memory_region(kvm, mem, user_alloc);
344 up_write(&current->mm->mmap_sem); 345 up_write(&kvm->slots_lock);
345 return r; 346 return r;
346} 347}
347EXPORT_SYMBOL_GPL(kvm_set_memory_region); 348EXPORT_SYMBOL_GPL(kvm_set_memory_region);