Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik...
authorLinus Torvalds <torvalds@g5.osdl.org>
Wed, 11 Oct 2006 18:19:30 +0000 (11:19 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Wed, 11 Oct 2006 18:19:30 +0000 (11:19 -0700)
* 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6: (42 commits)
  [PATCH] Fix section mismatch in de2104x.c
  [PATCH] sky2: set lower pause threshold to prevent overrun
  [PATCH] sky2: revert pci express extensions
  [PATCH] skge: version 1.9
  [PATCH] skge: better flow control negotiation
  [PATCH] skge: pause mapping for fiber
  [PATCH] skge: fix stuck irq when fiber down
  [PATCH] powerpc/cell spidernet release all descrs
  [PATCH] powerpc/cell spidernet DMA direction fix
  [PATCH] powerpc/cell spidernet variable name change
  [PATCH] powerpc/cell spidernet reduce DMA kicking
  [PATCH] powerpc/cell spidernet
  [PATCH] powerpc/cell spidernet refine locking
  [PATCH] powerpc/cell spidernet NAPI polling info.
  [PATCH] powerpc/cell spidernet low watermark patch.
  [PATCH] powerpc/cell spidernet incorrect offset
  [PATCH] powerpc/cell spidernet stop error printing patch.
  [PATCH] powerpc/cell spidernet fix error interrupt print
  [PATCH] powerpc/cell spidernet bogus rx interrupt bit
  [PATCH] Spidernet stop queue when queue is full.
  ...

217 files changed:
Documentation/filesystems/00-INDEX
Documentation/filesystems/ext4.txt [new file with mode: 0644]
Documentation/lockdep-design.txt
Documentation/sysctl/kernel.txt
Makefile
arch/alpha/kernel/alpha_ksyms.c
arch/alpha/kernel/core_irongate.c
arch/alpha/kernel/irq_alpha.c
arch/alpha/kernel/pci-noop.c
arch/alpha/kernel/pci_iommu.c
arch/alpha/kernel/process.c
arch/alpha/kernel/setup.c
arch/alpha/kernel/smp.c
arch/alpha/kernel/time.c
arch/alpha/mm/numa.c
arch/arm/kernel/armksyms.c
arch/arm/mach-versatile/core.c
arch/arm/mach-versatile/pci.c
arch/arm/vfp/vfpmodule.c
arch/arm26/kernel/armksyms.c
arch/avr32/kernel/time.c
arch/avr32/mach-at32ap/extint.c
arch/avr32/mach-at32ap/intc.c
arch/i386/Kconfig.cpu
arch/i386/kernel/io_apic.c
arch/i386/kernel/microcode.c
arch/i386/kernel/setup.c
arch/i386/kernel/syscall_table.S
arch/i386/lib/usercopy.c
arch/i386/mm/discontig.c
arch/ia64/mm/contig.c
arch/ia64/mm/discontig.c
arch/m32r/kernel/setup.c
arch/m32r/kernel/setup_mappi.c
arch/m32r/kernel/signal.c
arch/m32r/kernel/smp.c
arch/m32r/kernel/sys_m32r.c
arch/m32r/kernel/traps.c
arch/m68k/kernel/m68k_ksyms.c
arch/m68k/kernel/process.c
arch/m68k/kernel/setup.c
arch/m68k/kernel/traps.c
arch/m68k/mm/kmap.c
arch/m68k/mm/memory.c
arch/m68k/mm/sun3kmap.c
arch/m68k/sun3/Makefile
arch/m68k/sun3/idprom.c
arch/m68k/sun3/sun3_ksyms.c [deleted file]
arch/m68k/sun3/sun3dvma.c
arch/parisc/kernel/parisc_ksyms.c
arch/powerpc/mm/mem.c
arch/powerpc/mm/numa.c
arch/ppc/mm/init.c
arch/s390/kernel/s390_ksyms.c
arch/um/Kconfig
arch/um/Kconfig.i386
arch/um/Makefile-x86_64
arch/um/include/common-offsets.h
arch/um/include/longjmp.h
arch/um/include/os.h
arch/um/include/sysdep-i386/kernel-offsets.h
arch/um/include/sysdep-x86_64/kernel-offsets.h
arch/um/kernel/skas/mmu.c
arch/um/kernel/tt/uaccess_user.c
arch/um/os-Linux/tt.c
arch/um/os-Linux/util.c
arch/um/sys-x86_64/ksyms.c
arch/x86_64/kernel/io_apic.c
arch/x86_64/mm/init.c
arch/x86_64/mm/numa.c
drivers/block/DAC960.h
drivers/block/amiflop.c
drivers/block/xd.c
drivers/block/z2ram.c
drivers/char/ip2/i2lib.c
drivers/char/ip2/i2lib.h
drivers/char/ip2/ip2main.c
drivers/char/ipmi/ipmi_msghandler.c
drivers/char/tpm/tpm.c
drivers/char/tpm/tpm_atmel.c
drivers/char/tpm/tpm_nsc.c
drivers/eisa/eisa-bus.c
drivers/firmware/dell_rbu.c
drivers/firmware/efivars.c
drivers/ide/pci/generic.c
drivers/input/misc/wistron_btns.c
drivers/isdn/pcbit/layer2.c
drivers/isdn/sc/init.c
drivers/isdn/sc/packet.c
drivers/isdn/sc/shmem.c
drivers/mca/mca-bus.c
drivers/md/bitmap.c
drivers/net/eth16i.c
drivers/net/sun3_82586.c
drivers/net/sun3lance.c
drivers/pci/Kconfig
drivers/scsi/aha152x.c
drivers/scsi/dtc.c
drivers/scsi/fdomain.c
drivers/scsi/seagate.c
drivers/scsi/t128.c
drivers/scsi/wd7000.c
drivers/video/Kconfig
drivers/video/nvidia/nv_i2c.c
fs/Kconfig
fs/Makefile
fs/afs/dir.c
fs/autofs4/autofs_i.h
fs/autofs4/init.c
fs/autofs4/inode.c
fs/autofs4/waitq.c
fs/bio.c
fs/buffer.c
fs/compat_ioctl.c
fs/dcache.c
fs/eventpoll.c
fs/ext2/super.c
fs/ext3/super.c
fs/ext4/Makefile [new file with mode: 0644]
fs/ext4/acl.c [new file with mode: 0644]
fs/ext4/acl.h [new file with mode: 0644]
fs/ext4/balloc.c [new file with mode: 0644]
fs/ext4/bitmap.c [new file with mode: 0644]
fs/ext4/dir.c [new file with mode: 0644]
fs/ext4/extents.c [new file with mode: 0644]
fs/ext4/file.c [new file with mode: 0644]
fs/ext4/fsync.c [new file with mode: 0644]
fs/ext4/hash.c [new file with mode: 0644]
fs/ext4/ialloc.c [new file with mode: 0644]
fs/ext4/inode.c [new file with mode: 0644]
fs/ext4/ioctl.c [new file with mode: 0644]
fs/ext4/namei.c [new file with mode: 0644]
fs/ext4/namei.h [new file with mode: 0644]
fs/ext4/resize.c [new file with mode: 0644]
fs/ext4/super.c [new file with mode: 0644]
fs/ext4/symlink.c [new file with mode: 0644]
fs/ext4/xattr.c [new file with mode: 0644]
fs/ext4/xattr.h [new file with mode: 0644]
fs/ext4/xattr_security.c [new file with mode: 0644]
fs/ext4/xattr_trusted.c [new file with mode: 0644]
fs/ext4/xattr_user.c [new file with mode: 0644]
fs/fat/inode.c
fs/gfs2/locking/dlm/mount.c
fs/hugetlbfs/inode.c
fs/jbd/journal.c
fs/jbd2/Makefile [new file with mode: 0644]
fs/jbd2/checkpoint.c [new file with mode: 0644]
fs/jbd2/commit.c [new file with mode: 0644]
fs/jbd2/journal.c [new file with mode: 0644]
fs/jbd2/recovery.c [new file with mode: 0644]
fs/jbd2/revoke.c [new file with mode: 0644]
fs/jbd2/transaction.c [new file with mode: 0644]
fs/jffs2/super.c
fs/minix/inode.c
fs/ocfs2/super.c
fs/reiserfs/super.c
fs/super.c
fs/sysv/super.c
include/asm-alpha/io.h
include/asm-arm/arch-versatile/hardware.h
include/asm-arm/io.h
include/asm-arm/uaccess.h
include/asm-avr32/irq_regs.h [new file with mode: 0644]
include/asm-frv/io.h
include/asm-generic/bitops/sched.h
include/asm-i386/io.h
include/asm-i386/uaccess.h
include/asm-i386/unistd.h
include/asm-m32r/io.h
include/asm-m68k/uaccess.h
include/asm-mips/io.h
include/asm-powerpc/io.h
include/asm-ppc/io.h
include/asm-sh/io.h
include/asm-sh64/io.h
include/asm-sparc64/io.h
include/asm-x86_64/io.h
include/linux/bitmap.h
include/linux/carta_random32.h [new file with mode: 0644]
include/linux/compat_ioctl.h
include/linux/cpumask.h
include/linux/dcache.h
include/linux/ext4_fs.h [new file with mode: 0644]
include/linux/ext4_fs_extents.h [new file with mode: 0644]
include/linux/ext4_fs_i.h [new file with mode: 0644]
include/linux/ext4_fs_sb.h [new file with mode: 0644]
include/linux/ext4_jbd2.h [new file with mode: 0644]
include/linux/hugetlb.h
include/linux/io.h
include/linux/jbd2.h [new file with mode: 0644]
include/linux/magic.h
include/linux/mm.h
include/linux/module.h
include/linux/nbd.h
include/linux/nodemask.h
include/linux/syscalls.h
kernel/irq/proc.c
kernel/lockdep.c
kernel/module.c
kernel/power/disk.c
kernel/power/user.c
kernel/printk.c
kernel/profile.c
kernel/sched.c
kernel/workqueue.c
lib/Kconfig.debug
lib/Makefile
lib/bitmap.c
lib/carta_random32.c [new file with mode: 0644]
mm/hugetlb.c
mm/mempolicy.c
mm/page_alloc.c
mm/rmap.c
mm/shmem_acl.c
mm/truncate.c
scripts/kconfig/lxdialog/dialog.h
scripts/kernel-doc

index 3c384c0..4dc28cc 100644 (file)
@@ -34,6 +34,8 @@ ext2.txt
        - info, mount options and specifications for the Ext2 filesystem.
 ext3.txt
        - info, mount options and specifications for the Ext3 filesystem.
+ext4.txt
+       - info, mount options and specifications for the Ext4 filesystem.
 files.txt
        - info on file management in the Linux kernel.
 fuse.txt
diff --git a/Documentation/filesystems/ext4.txt b/Documentation/filesystems/ext4.txt
new file mode 100644 (file)
index 0000000..6a4adca
--- /dev/null
@@ -0,0 +1,236 @@
+
+Ext4 Filesystem
+===============
+
+This is a development version of the ext4 filesystem, an advanced level
+of the ext3 filesystem which incorporates scalability and reliability
+enhancements for supporting large filesystems (64 bit) in keeping with
+increasing disk capacities and state-of-the-art feature requirements.
+
+Mailing list: linux-ext4@vger.kernel.org
+
+
+1. Quick usage instructions:
+===========================
+
+  - Grab updated e2fsprogs from
+    ftp://ftp.kernel.org/pub/linux/kernel/people/tytso/e2fsprogs-interim/
+    This is a patchset on top of e2fsprogs-1.39, which can be found at
+    ftp://ftp.kernel.org/pub/linux/kernel/people/tytso/e2fsprogs/
+
+  - It's still mke2fs -j /dev/hda1
+
+  - mount /dev/hda1 /wherever -t ext4dev
+
+  - To enable extents,
+
+       mount /dev/hda1 /wherever -t ext4dev -o extents
+
+  - The filesystem is compatible with the ext3 driver until you add a file
+    which has extents (ie: `mount -o extents', then create a file).
+
+    NOTE: The "extents" mount flag is temporary.  It will soon go away and
+    extents will be enabled by the "-o extents" flag to mke2fs or tune2fs
+
+  - When comparing performance with other filesystems, remember that
+    ext3/4 by default offers higher data integrity guarantees than most.  So
+    when comparing with a metadata-only journalling filesystem, use `mount -o
+    data=writeback'.  And you might as well use `mount -o nobh' too along
+    with it.  Making the journal larger than the mke2fs default often helps
+    performance with metadata-intensive workloads.
+
+2. Features
+===========
+
+2.1 Currently available
+
+* ability to use filesystems > 16TB
+* extent format reduces metadata overhead (RAM, IO for access, transactions)
+* extent format more robust in face of on-disk corruption due to magics,
+* internal redunancy in tree
+
+2.1 Previously available, soon to be enabled by default by "mkefs.ext4":
+
+* dir_index and resize inode will be on by default
+* large inodes will be used by default for fast EAs, nsec timestamps, etc
+
+2.2 Candidate features for future inclusion
+
+There are several under discussion, whether they all make it in is
+partly a function of how much time everyone has to work on them:
+
+* improved file allocation (multi-block alloc, delayed alloc; basically done)
+* fix 32000 subdirectory limit (patch exists, needs some e2fsck work)
+* nsec timestamps for mtime, atime, ctime, create time (patch exists,
+  needs some e2fsck work)
+* inode version field on disk (NFSv4, Lustre; prototype exists)
+* reduced mke2fs/e2fsck time via uninitialized groups (prototype exists)
+* journal checksumming for robustness, performance (prototype exists)
+* persistent file preallocation (e.g for streaming media, databases)
+
+Features like metadata checksumming have been discussed and planned for
+a bit but no patches exist yet so I'm not sure they're in the near-term
+roadmap.
+
+The big performance win will come with mballoc and delalloc.  CFS has
+been using mballoc for a few years already with Lustre, and IBM + Bull
+did a lot of benchmarking on it.  The reason it isn't in the first set of
+patches is partly a manageability issue, and partly because it doesn't
+directly affect the on-disk format (outside of much better allocation)
+so it isn't critical to get into the first round of changes.  I believe
+Alex is working on a new set of patches right now.
+
+3. Options
+==========
+
+When mounting an ext4 filesystem, the following option are accepted:
+(*) == default
+
+extents                        ext4 will use extents to address file data.  The
+                       file system will no longer be mountable by ext3.
+
+journal=update         Update the ext4 file system's journal to the current
+                       format.
+
+journal=inum           When a journal already exists, this option is ignored.
+                       Otherwise, it specifies the number of the inode which
+                       will represent the ext4 file system's journal file.
+
+journal_dev=devnum     When the external journal device's major/minor numbers
+                       have changed, this option allows the user to specify
+                       the new journal location.  The journal device is
+                       identified through its new major/minor numbers encoded
+                       in devnum.
+
+noload                 Don't load the journal on mounting.
+
+data=journal           All data are committed into the journal prior to being
+                       written into the main file system.
+
+data=ordered   (*)     All data are forced directly out to the main file
+                       system prior to its metadata being committed to the
+                       journal.
+
+data=writeback         Data ordering is not preserved, data may be written
+                       into the main file system after its metadata has been
+                       committed to the journal.
+
+commit=nrsec   (*)     Ext4 can be told to sync all its data and metadata
+                       every 'nrsec' seconds. The default value is 5 seconds.
+                       This means that if you lose your power, you will lose
+                       as much as the latest 5 seconds of work (your
+                       filesystem will not be damaged though, thanks to the
+                       journaling).  This default value (or any low value)
+                       will hurt performance, but it's good for data-safety.
+                       Setting it to 0 will have the same effect as leaving
+                       it at the default (5 seconds).
+                       Setting it to very large values will improve
+                       performance.
+
+barrier=1              This enables/disables barriers.  barrier=0 disables
+                       it, barrier=1 enables it.
+
+orlov          (*)     This enables the new Orlov block allocator. It is
+                       enabled by default.
+
+oldalloc               This disables the Orlov block allocator and enables
+                       the old block allocator.  Orlov should have better
+                       performance - we'd like to get some feedback if it's
+                       the contrary for you.
+
+user_xattr             Enables Extended User Attributes.  Additionally, you
+                       need to have extended attribute support enabled in the
+                       kernel configuration (CONFIG_EXT4_FS_XATTR).  See the
+                       attr(5) manual page and http://acl.bestbits.at/ to
+                       learn more about extended attributes.
+
+nouser_xattr           Disables Extended User Attributes.
+
+acl                    Enables POSIX Access Control Lists support.
+                       Additionally, you need to have ACL support enabled in
+                       the kernel configuration (CONFIG_EXT4_FS_POSIX_ACL).
+                       See the acl(5) manual page and http://acl.bestbits.at/
+                       for more information.
+
+noacl                  This option disables POSIX Access Control List
+                       support.
+
+reservation
+
+noreservation
+
+bsddf          (*)     Make 'df' act like BSD.
+minixdf                        Make 'df' act like Minix.
+
+check=none             Don't do extra checking of bitmaps on mount.
+nocheck
+
+debug                  Extra debugging information is sent to syslog.
+
+errors=remount-ro(*)   Remount the filesystem read-only on an error.
+errors=continue                Keep going on a filesystem error.
+errors=panic           Panic and halt the machine if an error occurs.
+
+grpid                  Give objects the same group ID as their creator.
+bsdgroups
+
+nogrpid                (*)     New objects have the group ID of their creator.
+sysvgroups
+
+resgid=n               The group ID which may use the reserved blocks.
+
+resuid=n               The user ID which may use the reserved blocks.
+
+sb=n                   Use alternate superblock at this location.
+
+quota
+noquota
+grpquota
+usrquota
+
+bh             (*)     ext4 associates buffer heads to data pages to
+nobh                   (a) cache disk block mapping information
+                       (b) link pages into transaction to provide
+                           ordering guarantees.
+                       "bh" option forces use of buffer heads.
+                       "nobh" option tries to avoid associating buffer
+                       heads (supported only for "writeback" mode).
+
+
+Data Mode
+---------
+There are 3 different data modes:
+
+* writeback mode
+In data=writeback mode, ext4 does not journal data at all.  This mode provides
+a similar level of journaling as that of XFS, JFS, and ReiserFS in its default
+mode - metadata journaling.  A crash+recovery can cause incorrect data to
+appear in files which were written shortly before the crash.  This mode will
+typically provide the best ext4 performance.
+
+* ordered mode
+In data=ordered mode, ext4 only officially journals metadata, but it logically
+groups metadata and data blocks into a single unit called a transaction.  When
+it's time to write the new metadata out to disk, the associated data blocks
+are written first.  In general, this mode performs slightly slower than
+writeback but significantly faster than journal mode.
+
+* journal mode
+data=journal mode provides full data and metadata journaling.  All new data is
+written to the journal first, and then to its final location.
+In the event of a crash, the journal can be replayed, bringing both data and
+metadata into a consistent state.  This mode is the slowest except when data
+needs to be read from and written to disk at the same time where it
+outperforms all others modes.
+
+References
+==========
+
+kernel source: <file:fs/ext4/>
+               <file:fs/jbd2/>
+
+programs:      http://e2fsprogs.sourceforge.net/
+               http://ext2resize.sourceforge.net
+
+useful links:  http://fedoraproject.org/wiki/ext3-devel
+               http://www.bullopensource.org/ext4/
index dab123d..4887730 100644 (file)
@@ -50,10 +50,10 @@ The bit position indicates hardirq, softirq, hardirq-read,
 softirq-read respectively, and the character displayed in each
 indicates:
 
-   '.'  acquired while irqs enabled
+   '.'  acquired while irqs disabled
    '+'  acquired in irq context
-   '-'  acquired in process context with irqs disabled
-   '?'  read-acquired both with irqs enabled and in irq context
+   '-'  acquired with irqs enabled
+   '?' read acquired in irq context with irqs enabled.
 
 Unused mutexes cannot be part of the cause of an error.
 
index 89bf8c2..0bc7f1e 100644 (file)
@@ -86,7 +86,7 @@ valid for 30 seconds.
 core_pattern:
 
 core_pattern is used to specify a core dumpfile pattern name.
-. max length 64 characters; default value is "core"
+. max length 128 characters; default value is "core"
 . core_pattern is used as a pattern template for the output filename;
   certain string patterns (beginning with '%') are substituted with
   their actual values.
@@ -105,6 +105,9 @@ core_pattern is used to specify a core dumpfile pattern name.
        %h      hostname
        %e      executable filename
        %<OTHER> both are dropped
+. If the first character of the pattern is a '|', the kernel will treat
+  the rest of the pattern as a command to run.  The core dump will be
+  written to the standard input of that program instead of to a file.
 
 ==============================================================
 
index 274b780..f242829 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -741,6 +741,9 @@ endif # ifdef CONFIG_KALLSYMS
 
 # vmlinux image - including updated kernel symbols
 vmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) $(kallsyms.o) FORCE
+ifdef CONFIG_HEADERS_CHECK
+       $(Q)$(MAKE) headers_check
+endif
        $(call if_changed_rule,vmlinux__)
        $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $@
        $(Q)rm -f .old_version
index 8b02420..692809e 100644 (file)
@@ -6,41 +6,14 @@
  */
 
 #include <linux/module.h>
-#include <linux/string.h>
-#include <linux/user.h>
-#include <linux/elfcore.h>
-#include <linux/socket.h>
-#include <linux/syscalls.h>
-#include <linux/in.h>
-#include <linux/in6.h>
-#include <linux/pci.h>
-#include <linux/screen_info.h>
-#include <linux/tty.h>
-#include <linux/mm.h>
-#include <linux/delay.h>
-#include <linux/dma-mapping.h>
-
-#include <asm/io.h>
 #include <asm/console.h>
-#include <asm/hwrpb.h>
 #include <asm/uaccess.h>
-#include <asm/processor.h>
 #include <asm/checksum.h>
-#include <linux/interrupt.h>
 #include <asm/fpu.h>
-#include <asm/irq.h>
 #include <asm/machvec.h>
-#include <asm/pgalloc.h>
-#include <asm/semaphore.h>
-#include <asm/tlbflush.h>
-#include <asm/cacheflush.h>
-#include <asm/vga.h>
 
 #include <asm/unistd.h>
 
-extern struct hwrpb_struct *hwrpb;
-extern spinlock_t rtc_lock;
-
 /* these are C runtime functions with special calling conventions: */
 extern void __divl (void);
 extern void __reml (void);
@@ -52,14 +25,9 @@ extern void __divqu (void);
 extern void __remqu (void);
 
 EXPORT_SYMBOL(alpha_mv);
-EXPORT_SYMBOL(screen_info);
-EXPORT_SYMBOL(perf_irq);
 EXPORT_SYMBOL(callback_getenv);
 EXPORT_SYMBOL(callback_setenv);
 EXPORT_SYMBOL(callback_save_env);
-#ifdef CONFIG_ALPHA_GENERIC
-EXPORT_SYMBOL(alpha_using_srm);
-#endif /* CONFIG_ALPHA_GENERIC */
 
 /* platform dependent support */
 EXPORT_SYMBOL(strcat);
@@ -77,47 +45,14 @@ EXPORT_SYMBOL(__constant_c_memset);
 EXPORT_SYMBOL(copy_page);
 EXPORT_SYMBOL(clear_page);
 
-EXPORT_SYMBOL(__direct_map_base);
-EXPORT_SYMBOL(__direct_map_size);
-
-#ifdef CONFIG_PCI
-EXPORT_SYMBOL(pci_alloc_consistent);
-EXPORT_SYMBOL(pci_free_consistent);
-EXPORT_SYMBOL(pci_map_single);
-EXPORT_SYMBOL(pci_map_page);
-EXPORT_SYMBOL(pci_unmap_single);
-EXPORT_SYMBOL(pci_unmap_page);
-EXPORT_SYMBOL(pci_map_sg);
-EXPORT_SYMBOL(pci_unmap_sg);
-EXPORT_SYMBOL(pci_dma_supported);
-EXPORT_SYMBOL(pci_dac_dma_supported);
-EXPORT_SYMBOL(pci_dac_page_to_dma);
-EXPORT_SYMBOL(pci_dac_dma_to_page);
-EXPORT_SYMBOL(pci_dac_dma_to_offset);
-EXPORT_SYMBOL(alpha_gendev_to_pci);
-#endif
-EXPORT_SYMBOL(dma_set_mask);
-
-EXPORT_SYMBOL(dump_thread);
-EXPORT_SYMBOL(dump_elf_thread);
-EXPORT_SYMBOL(dump_elf_task);
-EXPORT_SYMBOL(dump_elf_task_fp);
-EXPORT_SYMBOL(hwrpb);
-EXPORT_SYMBOL(start_thread);
 EXPORT_SYMBOL(alpha_read_fp_reg);
 EXPORT_SYMBOL(alpha_read_fp_reg_s);
 EXPORT_SYMBOL(alpha_write_fp_reg);
 EXPORT_SYMBOL(alpha_write_fp_reg_s);
 
-/* In-kernel system calls.  */
+/* entry.S */
 EXPORT_SYMBOL(kernel_thread);
-EXPORT_SYMBOL(sys_dup);
-EXPORT_SYMBOL(sys_exit);
-EXPORT_SYMBOL(sys_write);
-EXPORT_SYMBOL(sys_lseek);
 EXPORT_SYMBOL(kernel_execve);
-EXPORT_SYMBOL(sys_setsid);
-EXPORT_SYMBOL(sys_wait4);
 
 /* Networking helper routines. */
 EXPORT_SYMBOL(csum_tcpudp_magic);
@@ -134,10 +69,6 @@ EXPORT_SYMBOL(alpha_fp_emul_imprecise);
 EXPORT_SYMBOL(alpha_fp_emul);
 #endif
 
-#ifdef CONFIG_ALPHA_BROKEN_IRQ_MASK
-EXPORT_SYMBOL(__min_ipl);
-#endif
-
 /*
  * The following are specially called from the uaccess assembly stubs.
  */
@@ -160,26 +91,9 @@ EXPORT_SYMBOL(up);
  */
 
 #ifdef CONFIG_SMP
-EXPORT_SYMBOL(flush_tlb_mm);
-EXPORT_SYMBOL(flush_tlb_range);
-EXPORT_SYMBOL(flush_tlb_page);
-EXPORT_SYMBOL(smp_imb);
-EXPORT_SYMBOL(cpu_data);
-EXPORT_SYMBOL(smp_num_cpus);
-EXPORT_SYMBOL(smp_call_function);
-EXPORT_SYMBOL(smp_call_function_on_cpu);
 EXPORT_SYMBOL(_atomic_dec_and_lock);
 #endif /* CONFIG_SMP */
 
-/*
- * NUMA specific symbols
- */
-#ifdef CONFIG_DISCONTIGMEM
-EXPORT_SYMBOL(node_data);
-#endif /* CONFIG_DISCONTIGMEM */
-
-EXPORT_SYMBOL(rtc_lock);
-
 /*
  * The following are special because they're not called
  * explicitly (the C compiler or assembler generates them in
@@ -200,8 +114,3 @@ EXPORT_SYMBOL(__remqu);
 EXPORT_SYMBOL(memcpy);
 EXPORT_SYMBOL(memset);
 EXPORT_SYMBOL(memchr);
-
-#ifdef CONFIG_ALPHA_IRONGATE
-EXPORT_SYMBOL(irongate_ioremap);
-EXPORT_SYMBOL(irongate_iounmap);
-#endif
index 138d497..e4a0bcf 100644 (file)
@@ -404,6 +404,7 @@ irongate_ioremap(unsigned long addr, unsigned long size)
 #endif
        return (void __iomem *)vaddr;
 }
+EXPORT_SYMBOL(irongate_ioremap);
 
 void
 irongate_iounmap(volatile void __iomem *xaddr)
@@ -414,3 +415,4 @@ irongate_iounmap(volatile void __iomem *xaddr)
        if (addr)
                return vfree((void *)(PAGE_MASK & addr)); 
 }
+EXPORT_SYMBOL(irongate_iounmap);
index 6dd126b..e16aeb6 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/sched.h>
 #include <linux/irq.h>
 #include <linux/kernel_stat.h>
+#include <linux/module.h>
 
 #include <asm/machvec.h>
 #include <asm/dma.h>
@@ -16,6 +17,7 @@
 /* Hack minimum IPL during interrupt processing for broken hardware.  */
 #ifdef CONFIG_ALPHA_BROKEN_IRQ_MASK
 int __min_ipl;
+EXPORT_SYMBOL(__min_ipl);
 #endif
 
 /*
@@ -30,6 +32,7 @@ dummy_perf(unsigned long vector, struct pt_regs *regs)
 }
 
 void (*perf_irq)(unsigned long, struct pt_regs *) = dummy_perf;
+EXPORT_SYMBOL(perf_irq);
 
 /*
  * The main interrupt entry point.
index fff5cf9..174b729 100644 (file)
@@ -201,6 +201,7 @@ dma_set_mask(struct device *dev, u64 mask)
 
        return 0;
 }
+EXPORT_SYMBOL(dma_set_mask);
 
 void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
 {
index c468e31..6e7d1fe 100644 (file)
@@ -300,6 +300,7 @@ pci_map_single(struct pci_dev *pdev, void *cpu_addr, size_t size, int dir)
        dac_allowed = pdev ? pci_dac_dma_supported(pdev, pdev->dma_mask) : 0; 
        return pci_map_single_1(pdev, cpu_addr, size, dac_allowed);
 }
+EXPORT_SYMBOL(pci_map_single);
 
 dma_addr_t
 pci_map_page(struct pci_dev *pdev, struct page *page, unsigned long offset,
@@ -314,6 +315,7 @@ pci_map_page(struct pci_dev *pdev, struct page *page, unsigned long offset,
        return pci_map_single_1(pdev, (char *)page_address(page) + offset, 
                                size, dac_allowed);
 }
+EXPORT_SYMBOL(pci_map_page);
 
 /* Unmap a single streaming mode DMA translation.  The DMA_ADDR and
    SIZE must match what was provided for in a previous pci_map_single
@@ -379,6 +381,7 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, size_t size,
        DBGA2("pci_unmap_single: sg [%lx,%lx] np %ld from %p\n",
              dma_addr, size, npages, __builtin_return_address(0));
 }
+EXPORT_SYMBOL(pci_unmap_single);
 
 void
 pci_unmap_page(struct pci_dev *pdev, dma_addr_t dma_addr,
@@ -386,6 +389,7 @@ pci_unmap_page(struct pci_dev *pdev, dma_addr_t dma_addr,
 {
        pci_unmap_single(pdev, dma_addr, size, direction);
 }
+EXPORT_SYMBOL(pci_unmap_page);
 
 /* Allocate and map kernel buffer using consistent mode DMA for PCI
    device.  Returns non-NULL cpu-view pointer to the buffer if
@@ -427,6 +431,7 @@ try_again:
 
        return cpu_addr;
 }
+EXPORT_SYMBOL(pci_alloc_consistent);
 
 /* Free and unmap a consistent DMA buffer.  CPU_ADDR and DMA_ADDR must
    be values that were returned from pci_alloc_consistent.  SIZE must
@@ -444,7 +449,7 @@ pci_free_consistent(struct pci_dev *pdev, size_t size, void *cpu_addr,
        DBGA2("pci_free_consistent: [%x,%lx] from %p\n",
              dma_addr, size, __builtin_return_address(0));
 }
-
+EXPORT_SYMBOL(pci_free_consistent);
 
 /* Classify the elements of the scatterlist.  Write dma_address
    of each element with:
@@ -672,6 +677,7 @@ pci_map_sg(struct pci_dev *pdev, struct scatterlist *sg, int nents,
                pci_unmap_sg(pdev, start, out - start, direction);
        return 0;
 }
+EXPORT_SYMBOL(pci_map_sg);
 
 /* Unmap a set of streaming mode DMA translations.  Again, cpu read
    rules concerning calls here are the same as for pci_unmap_single()
@@ -752,6 +758,7 @@ pci_unmap_sg(struct pci_dev *pdev, struct scatterlist *sg, int nents,
 
        DBGA("pci_unmap_sg: %ld entries\n", nents - (end - sg));
 }
+EXPORT_SYMBOL(pci_unmap_sg);
 
 
 /* Return whether the given PCI device DMA address mask can be
@@ -786,6 +793,7 @@ pci_dma_supported(struct pci_dev *pdev, u64 mask)
 
        return 0;
 }
+EXPORT_SYMBOL(pci_dma_supported);
 
 \f
 /*
@@ -908,6 +916,7 @@ pci_dac_dma_supported(struct pci_dev *dev, u64 mask)
 
        return ok;
 }
+EXPORT_SYMBOL(pci_dac_dma_supported);
 
 dma64_addr_t
 pci_dac_page_to_dma(struct pci_dev *pdev, struct page *page,
@@ -917,6 +926,7 @@ pci_dac_page_to_dma(struct pci_dev *pdev, struct page *page,
                + __pa(page_address(page)) 
                + (dma64_addr_t) offset);
 }
+EXPORT_SYMBOL(pci_dac_page_to_dma);
 
 struct page *
 pci_dac_dma_to_page(struct pci_dev *pdev, dma64_addr_t dma_addr)
@@ -924,13 +934,14 @@ pci_dac_dma_to_page(struct pci_dev *pdev, dma64_addr_t dma_addr)
        unsigned long paddr = (dma_addr & PAGE_MASK) - alpha_mv.pci_dac_offset;
        return virt_to_page(__va(paddr));
 }
+EXPORT_SYMBOL(pci_dac_dma_to_page);
 
 unsigned long
 pci_dac_dma_to_offset(struct pci_dev *pdev, dma64_addr_t dma_addr)
 {
        return (dma_addr & ~PAGE_MASK);
 }
-
+EXPORT_SYMBOL(pci_dac_dma_to_offset);
 
 /* Helper for generic DMA-mapping functions. */
 
@@ -957,6 +968,7 @@ alpha_gendev_to_pci(struct device *dev)
        /* This assumes ISA bus master with dma_mask 0xffffff. */
        return NULL;
 }
+EXPORT_SYMBOL(alpha_gendev_to_pci);
 
 int
 dma_set_mask(struct device *dev, u64 mask)
@@ -969,3 +981,4 @@ dma_set_mask(struct device *dev, u64 mask)
 
        return 0;
 }
+EXPORT_SYMBOL(dma_set_mask);
index b3a8a29..3370e6f 100644 (file)
@@ -205,6 +205,7 @@ start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp)
        regs->ps = 8;
        wrusp(sp);
 }
+EXPORT_SYMBOL(start_thread);
 
 /*
  * Free current thread data structures etc..
@@ -376,6 +377,7 @@ dump_thread(struct pt_regs * pt, struct user * dump)
        dump->regs[EF_A2]  = pt->r18;
        memcpy((char *)dump->regs + EF_SIZE, sw->fp, 32 * 8);
 }
+EXPORT_SYMBOL(dump_thread);
 
 /*
  * Fill in the user structure for a ELF core dump.
@@ -424,6 +426,7 @@ dump_elf_thread(elf_greg_t *dest, struct pt_regs *pt, struct thread_info *ti)
           useful value of the thread's UNIQUE field.  */
        dest[32] = ti->pcb.unique;
 }
+EXPORT_SYMBOL(dump_elf_thread);
 
 int
 dump_elf_task(elf_greg_t *dest, struct task_struct *task)
@@ -431,6 +434,7 @@ dump_elf_task(elf_greg_t *dest, struct task_struct *task)
        dump_elf_thread(dest, task_pt_regs(task), task_thread_info(task));
        return 1;
 }
+EXPORT_SYMBOL(dump_elf_task);
 
 int
 dump_elf_task_fp(elf_fpreg_t *dest, struct task_struct *task)
@@ -439,6 +443,7 @@ dump_elf_task_fp(elf_fpreg_t *dest, struct task_struct *task)
        memcpy(dest, sw->fp, 32 * 8);
        return 1;
 }
+EXPORT_SYMBOL(dump_elf_task_fp);
 
 /*
  * sys_execve() executes a new program.
index a94e6d9..1aea7c7 100644 (file)
@@ -66,6 +66,7 @@ static struct notifier_block alpha_panic_block = {
 
 
 struct hwrpb_struct *hwrpb;
+EXPORT_SYMBOL(hwrpb);
 unsigned long srm_hae;
 
 int alpha_l1i_cacheshape;
@@ -111,6 +112,7 @@ unsigned long alpha_agpgart_size = DEFAULT_AGP_APER_SIZE;
 #ifdef CONFIG_ALPHA_GENERIC
 struct alpha_machine_vector alpha_mv;
 int alpha_using_srm;
+EXPORT_SYMBOL(alpha_using_srm);
 #endif
 
 static struct alpha_machine_vector *get_sysvec(unsigned long, unsigned long,
@@ -137,6 +139,8 @@ struct screen_info screen_info = {
        .orig_video_points = 16
 };
 
+EXPORT_SYMBOL(screen_info);
+
 /*
  * The direct map I/O window, if any.  This should be the same
  * for all busses, since it's used by virt_to_bus.
@@ -144,6 +148,8 @@ struct screen_info screen_info = {
 
 unsigned long __direct_map_base;
 unsigned long __direct_map_size;
+EXPORT_SYMBOL(__direct_map_base);
+EXPORT_SYMBOL(__direct_map_size);
 
 /*
  * Declare all of the machine vectors.
index 596780e..d1ec4f5 100644 (file)
@@ -52,6 +52,7 @@
 
 /* A collection of per-processor data.  */
 struct cpuinfo_alpha cpu_data[NR_CPUS];
+EXPORT_SYMBOL(cpu_data);
 
 /* A collection of single bit ipi messages.  */
 static struct {
@@ -74,6 +75,7 @@ EXPORT_SYMBOL(cpu_online_map);
 
 int smp_num_probed;            /* Internal processor count */
 int smp_num_cpus = 1;          /* Number that came online.  */
+EXPORT_SYMBOL(smp_num_cpus);
 
 extern void calibrate_delay(void);
 
@@ -790,6 +792,7 @@ smp_call_function_on_cpu (void (*func) (void *info), void *info, int retry,
 
        return 0;
 }
+EXPORT_SYMBOL(smp_call_function_on_cpu);
 
 int
 smp_call_function (void (*func) (void *info), void *info, int retry, int wait)
@@ -797,6 +800,7 @@ smp_call_function (void (*func) (void *info), void *info, int retry, int wait)
        return smp_call_function_on_cpu (func, info, retry, wait,
                                         cpu_online_map);
 }
+EXPORT_SYMBOL(smp_call_function);
 
 static void
 ipi_imb(void *ignored)
@@ -811,6 +815,7 @@ smp_imb(void)
        if (on_each_cpu(ipi_imb, NULL, 1, 1))
                printk(KERN_CRIT "smp_imb: timed out\n");
 }
+EXPORT_SYMBOL(smp_imb);
 
 static void
 ipi_flush_tlb_all(void *ignored)
@@ -866,6 +871,7 @@ flush_tlb_mm(struct mm_struct *mm)
 
        preempt_enable();
 }
+EXPORT_SYMBOL(flush_tlb_mm);
 
 struct flush_tlb_page_struct {
        struct vm_area_struct *vma;
@@ -918,6 +924,7 @@ flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
 
        preempt_enable();
 }
+EXPORT_SYMBOL(flush_tlb_page);
 
 void
 flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end)
@@ -925,6 +932,7 @@ flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long e
        /* On the Alpha we always flush the whole user tlb.  */
        flush_tlb_mm(vma->vm_mm);
 }
+EXPORT_SYMBOL(flush_tlb_range);
 
 static void
 ipi_flush_icache_page(void *x)
index cf06665..d7053eb 100644 (file)
@@ -57,6 +57,7 @@
 static int set_rtc_mmss(unsigned long);
 
 DEFINE_SPINLOCK(rtc_lock);
+EXPORT_SYMBOL(rtc_lock);
 
 #define TICK_SIZE (tick_nsec / 1000)
 
index b826f58..e3e3806 100644 (file)
 #include <linux/swap.h>
 #include <linux/initrd.h>
 #include <linux/pfn.h>
+#include <linux/module.h>
 
 #include <asm/hwrpb.h>
 #include <asm/pgalloc.h>
 
 pg_data_t node_data[MAX_NUMNODES];
 bootmem_data_t node_bdata[MAX_NUMNODES];
+EXPORT_SYMBOL(node_data);
 
 #undef DEBUG_DISCONTIG
 #ifdef DEBUG_DISCONTIG
index da69e66..4779f47 100644 (file)
@@ -178,9 +178,3 @@ EXPORT_SYMBOL(_find_next_zero_bit_be);
 EXPORT_SYMBOL(_find_first_bit_be);
 EXPORT_SYMBOL(_find_next_bit_be);
 #endif
-
-       /* syscalls */
-EXPORT_SYMBOL(sys_write);
-EXPORT_SYMBOL(sys_lseek);
-EXPORT_SYMBOL(sys_exit);
-EXPORT_SYMBOL(sys_wait4);
index 2aa150b..3b85761 100644 (file)
@@ -188,12 +188,12 @@ static struct map_desc versatile_io_desc[] __initdata = {
                .length         = SZ_4K,
                .type           = MT_DEVICE
        }, {
-               .virtual        =  VERSATILE_PCI_VIRT_BASE,
+               .virtual        =  (unsigned long)VERSATILE_PCI_VIRT_BASE,
                .pfn            = __phys_to_pfn(VERSATILE_PCI_BASE),
                .length         = VERSATILE_PCI_BASE_SIZE,
                .type           = MT_DEVICE
        }, {
-               .virtual        =  VERSATILE_PCI_CFG_VIRT_BASE,
+               .virtual        =  (unsigned long)VERSATILE_PCI_CFG_VIRT_BASE,
                .pfn            = __phys_to_pfn(VERSATILE_PCI_CFG_BASE),
                .length         = VERSATILE_PCI_CFG_BASE_SIZE,
                .type           = MT_DEVICE
index 13bbd08..5cd0b5d 100644 (file)
  * Cfg   42000000 - 42FFFFFF     PCI config
  *
  */
-#define SYS_PCICTL                     IO_ADDRESS(VERSATILE_SYS_PCICTL)
-#define PCI_IMAP0                      IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x0)
-#define PCI_IMAP1                      IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x4)
-#define PCI_IMAP2                      IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x8)
-#define PCI_SMAP0                      IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x10)
-#define PCI_SMAP1                      IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x14)
-#define PCI_SMAP2                      IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x18)
-#define PCI_SELFID                     IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0xc)
+#define __IO_ADDRESS(n) ((void __iomem *)(unsigned long)IO_ADDRESS(n))
+#define SYS_PCICTL             __IO_ADDRESS(VERSATILE_SYS_PCICTL)
+#define PCI_IMAP0              __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x0)
+#define PCI_IMAP1              __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x4)
+#define PCI_IMAP2              __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x8)
+#define PCI_SMAP0              __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x10)
+#define PCI_SMAP1              __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x14)
+#define PCI_SMAP2              __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x18)
+#define PCI_SELFID             __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0xc)
 
 #define DEVICE_ID_OFFSET               0x00
 #define CSR_OFFSET                     0x04
@@ -76,7 +77,7 @@ static int __init versatile_pci_slot_ignore(char *str)
 __setup("pci_slot_ignore=", versatile_pci_slot_ignore);
 
 
-static unsigned long __pci_addr(struct pci_bus *bus,
+static void __iomem *__pci_addr(struct pci_bus *bus,
                                unsigned int devfn, int offset)
 {
        unsigned int busnr = bus->number;
@@ -91,14 +92,14 @@ static unsigned long __pci_addr(struct pci_bus *bus,
        if (devfn > 255)
                BUG();
 
-       return (VERSATILE_PCI_CFG_VIRT_BASE | (busnr << 16) |
+       return VERSATILE_PCI_CFG_VIRT_BASE + ((busnr << 16) |
                (PCI_SLOT(devfn) << 11) | (PCI_FUNC(devfn) << 8) | offset);
 }
 
 static int versatile_read_config(struct pci_bus *bus, unsigned int devfn, int where,
                                 int size, u32 *val)
 {
-       unsigned long addr = __pci_addr(bus, devfn, where);
+       void __iomem *addr = __pci_addr(bus, devfn, where & ~3);
        u32 v;
        int slot = PCI_SLOT(devfn);
 
@@ -121,13 +122,12 @@ static int versatile_read_config(struct pci_bus *bus, unsigned int devfn, int wh
                        break;
 
                case 2:
-                       v = __raw_readl(addr & ~3);
-                       if (addr & 2) v >>= 16;
+                       v = __raw_readl(addr);
+                       if (where & 2) v >>= 16;
                        v &= 0xffff;
                        break;
 
                default:
-                       addr &= ~3;
                        v = __raw_readl(addr);
                        break;
                }
@@ -140,7 +140,7 @@ static int versatile_read_config(struct pci_bus *bus, unsigned int devfn, int wh
 static int versatile_write_config(struct pci_bus *bus, unsigned int devfn, int where,
                                  int size, u32 val)
 {
-       unsigned long addr = __pci_addr(bus, devfn, where);
+       void __iomem *addr = __pci_addr(bus, devfn, where);
        int slot = PCI_SLOT(devfn);
 
        if (pci_slot_ignore & (1 << slot)) {
@@ -279,7 +279,7 @@ int __init pci_versatile_setup(int nr, struct pci_sys_data *sys)
        printk("PCI core found (slot %d)\n",myslot);
 
        __raw_writel(myslot, PCI_SELFID);
-       local_pci_cfg_base = (void *) VERSATILE_PCI_CFG_VIRT_BASE + (myslot << 11);
+       local_pci_cfg_base = VERSATILE_PCI_CFG_VIRT_BASE + (myslot << 11);
 
        val = __raw_readl(local_pci_cfg_base + CSR_OFFSET);
        val |= PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE;
index dedbb44..a657a28 100644 (file)
@@ -90,7 +90,7 @@ void vfp_raise_sigfpe(unsigned int sicode, struct pt_regs *regs)
 
        info.si_signo = SIGFPE;
        info.si_code = sicode;
-       info.si_addr = (void *)(instruction_pointer(regs) - 4);
+       info.si_addr = (void __user *)(instruction_pointer(regs) - 4);
 
        /*
         * This is the same as NWFPE, because it's not clear what
index 07907b6..93293d0 100644 (file)
@@ -202,14 +202,6 @@ EXPORT_SYMBOL(_find_next_zero_bit_le);
 EXPORT_SYMBOL(elf_platform);
 EXPORT_SYMBOL(elf_hwcap);
 
-       /* syscalls */
-EXPORT_SYMBOL(sys_write);
-EXPORT_SYMBOL(sys_read);
-EXPORT_SYMBOL(sys_lseek);
-EXPORT_SYMBOL(sys_open);
-EXPORT_SYMBOL(sys_exit);
-EXPORT_SYMBOL(sys_wait4);
-
 #ifdef CONFIG_PREEMPT
 EXPORT_SYMBOL(kernel_flag);
 #endif
index 3e56b9f..5a247ba 100644 (file)
@@ -124,15 +124,15 @@ unsigned long long sched_clock(void)
  *
  * In UP mode, it is invoked from the (global) timer_interrupt.
  */
-static void local_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static void local_timer_interrupt(int irq, void *dev_id)
 {
        if (current->pid)
-               profile_tick(CPU_PROFILING, regs);
-       update_process_times(user_mode(regs));
+               profile_tick(CPU_PROFILING);
+       update_process_times(user_mode(get_irq_regs()));
 }
 
 static irqreturn_t
-timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+timer_interrupt(int irq, void *dev_id)
 {
        unsigned int count;
 
@@ -157,7 +157,7 @@ timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
         *
         * SMP is not supported yet.
         */
-       local_timer_interrupt(irq, dev_id, regs);
+       local_timer_interrupt(irq, dev_id);
 
        return IRQ_HANDLED;
 }
index 7da9c5f..4dff1f9 100644 (file)
@@ -102,8 +102,7 @@ struct irq_chip eim_chip = {
        .set_type       = eim_set_irq_type,
 };
 
-static void demux_eim_irq(unsigned int irq, struct irq_desc *desc,
-                         struct pt_regs *regs)
+static void demux_eim_irq(unsigned int irq, struct irq_desc *desc)
 {
        struct at32_sm *sm = desc->handler_data;
        struct irq_desc *ext_desc;
@@ -121,7 +120,7 @@ static void demux_eim_irq(unsigned int irq, struct irq_desc *desc,
 
                ext_irq = i + sm->eim_first_irq;
                ext_desc = irq_desc + ext_irq;
-               ext_desc->handle_irq(ext_irq, ext_desc, regs);
+               ext_desc->handle_irq(ext_irq, ext_desc);
        }
 
        spin_unlock(&sm->lock);
index 74f8c9f..eb87a18 100644 (file)
@@ -52,16 +52,19 @@ static struct intc intc0 = {
 asmlinkage void do_IRQ(int level, struct pt_regs *regs)
 {
        struct irq_desc *desc;
+       struct pt_regs *old_regs;
        unsigned int irq;
        unsigned long status_reg;
 
        local_irq_disable();
 
+       old_regs = set_irq_regs(regs);
+
        irq_enter();
 
        irq = intc_readl(&intc0, INTCAUSE0 - 4 * level);
        desc = irq_desc + irq;
-       desc->handle_irq(irq, desc, regs);
+       desc->handle_irq(irq, desc);
 
        /*
         * Clear all interrupt level masks so that we may handle
@@ -75,6 +78,8 @@ asmlinkage void do_IRQ(int level, struct pt_regs *regs)
        sysreg_write(SR, status_reg);
 
        irq_exit();
+
+       set_irq_regs(old_regs);
 }
 
 void __init init_IRQ(void)
index 21c9a4e..fc4f2ab 100644 (file)
@@ -7,6 +7,7 @@ choice
 
 config M386
        bool "386"
+       depends on !UML
        ---help---
          This is the processor type of your CPU. This information is used for
          optimizing purposes. In order to compile a kernel that can run on
@@ -301,7 +302,7 @@ config X86_USE_PPRO_CHECKSUM
 
 config X86_USE_3DNOW
        bool
-       depends on MCYRIXIII || MK7 || MGEODE_LX
+       depends on (MCYRIXIII || MK7 || MGEODE_LX) && !UML
        default y
 
 config X86_OOSTORE
index cd082c3..27bceaf 100644 (file)
@@ -2594,7 +2594,7 @@ static void set_ht_irq_affinity(unsigned int irq, cpumask_t mask)
 }
 #endif
 
-static struct hw_interrupt_type ht_irq_chip = {
+static struct irq_chip ht_irq_chip = {
        .name           = "PCI-HT",
        .mask           = mask_ht_irq,
        .unmask         = unmask_ht_irq,
index 9b94797..c4d0291 100644 (file)
@@ -656,14 +656,18 @@ static struct attribute_group mc_attr_group = {
 
 static int mc_sysdev_add(struct sys_device *sys_dev)
 {
-       int cpu = sys_dev->id;
+       int err, cpu = sys_dev->id;
        struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
 
        if (!cpu_online(cpu))
                return 0;
+
        pr_debug("Microcode:CPU %d added\n", cpu);
        memset(uci, 0, sizeof(*uci));
-       sysfs_create_group(&sys_dev->kobj, &mc_attr_group);
+
+       err = sysfs_create_group(&sys_dev->kobj, &mc_attr_group);
+       if (err)
+               return err;
 
        microcode_init_cpu(cpu);
        return 0;
index 000cf03..519e63c 100644 (file)
@@ -1083,16 +1083,15 @@ static unsigned long __init setup_memory(void)
 
 void __init zone_sizes_init(void)
 {
+       unsigned long max_zone_pfns[MAX_NR_ZONES];
+       memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+       max_zone_pfns[ZONE_DMA] =
+               virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
+       max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
 #ifdef CONFIG_HIGHMEM
-       unsigned long max_zone_pfns[MAX_NR_ZONES] = {
-                       virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT,
-                       max_low_pfn,
-                       highend_pfn};
+       max_zone_pfns[ZONE_HIGHMEM] = highend_pfn;
        add_active_range(0, 0, highend_pfn);
 #else
-       unsigned long max_zone_pfns[MAX_NR_ZONES] = {
-                       virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT,
-                       max_low_pfn};
        add_active_range(0, 0, max_low_pfn);
 #endif
 
index 7e639f7..2697e92 100644 (file)
@@ -318,3 +318,4 @@ ENTRY(sys_call_table)
        .long sys_vmsplice
        .long sys_move_pages
        .long sys_getcpu
+       .long sys_epoll_pwait
index 08502fc..258df6b 100644 (file)
@@ -179,7 +179,7 @@ __clear_user(void __user *to, unsigned long n)
 EXPORT_SYMBOL(__clear_user);
 
 /**
- * strlen_user: - Get the size of a string in user space.
+ * strnlen_user: - Get the size of a string in user space.
  * @s: The string to measure.
  * @n: The maximum valid length
  *
index 455597d..ddbdb03 100644 (file)
@@ -356,11 +356,12 @@ void __init numa_kva_reserve(void)
 void __init zone_sizes_init(void)
 {
        int nid;
-       unsigned long max_zone_pfns[MAX_NR_ZONES] = {
-               virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT,
-               max_low_pfn,
-               highend_pfn
-       };
+       unsigned long max_zone_pfns[MAX_NR_ZONES];
+       memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+       max_zone_pfns[ZONE_DMA] =
+               virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
+       max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
+       max_zone_pfns[ZONE_HIGHMEM] = highend_pfn;
 
        /* If SRAT has not registered memory, register it now */
        if (find_max_pfn_with_active_regions() == 0) {
index daf977f..82deaa3 100644 (file)
@@ -233,6 +233,7 @@ paging_init (void)
        efi_memmap_walk(count_pages, &num_physpages);
 
        max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT;
+       memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
        max_zone_pfns[ZONE_DMA] = max_dma;
        max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
 
index d497b6b..96722cb 100644 (file)
@@ -709,6 +709,7 @@ void __init paging_init(void)
                        max_pfn = mem_data[node].max_pfn;
        }
 
+       memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
        max_zone_pfns[ZONE_DMA] = max_dma;
        max_zone_pfns[ZONE_NORMAL] = max_pfn;
        free_area_init_nodes(max_zone_pfns);
index 3f35ab3..0e7778b 100644 (file)
@@ -369,10 +369,10 @@ static void c_stop(struct seq_file *m, void *v)
 }
 
 struct seq_operations cpuinfo_op = {
-       start:  c_start,
-       next:   c_next,
-       stop:   c_stop,
-       show:   show_cpuinfo,
+       .start = c_start,
+       .next = c_next,
+       .stop = c_stop,
+       .show = show_cpuinfo,
 };
 #endif /* CONFIG_PROC_FS */
 
index 67dbbdc..6b2d77d 100644 (file)
@@ -86,7 +86,7 @@ void __init init_IRQ(void)
        /* INT0 : LAN controller (RTL8019AS) */
        irq_desc[M32R_IRQ_INT0].status = IRQ_DISABLED;
        irq_desc[M32R_IRQ_INT0].chip = &mappi_irq_type;
-       irq_desc[M32R_IRQ_INT0].action = 0;
+       irq_desc[M32R_IRQ_INT0].action = NULL;
        irq_desc[M32R_IRQ_INT0].depth = 1;
        icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
        disable_mappi_irq(M32R_IRQ_INT0);
@@ -95,7 +95,7 @@ void __init init_IRQ(void)
        /* MFT2 : system timer */
        irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED;
        irq_desc[M32R_IRQ_MFT2].chip = &mappi_irq_type;
-       irq_desc[M32R_IRQ_MFT2].action = 0;
+       irq_desc[M32R_IRQ_MFT2].action = NULL;
        irq_desc[M32R_IRQ_MFT2].depth = 1;
        icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
        disable_mappi_irq(M32R_IRQ_MFT2);
@@ -104,7 +104,7 @@ void __init init_IRQ(void)
        /* SIO0_R : uart receive data */
        irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED;
        irq_desc[M32R_IRQ_SIO0_R].chip = &mappi_irq_type;
-       irq_desc[M32R_IRQ_SIO0_R].action = 0;
+       irq_desc[M32R_IRQ_SIO0_R].action = NULL;
        irq_desc[M32R_IRQ_SIO0_R].depth = 1;
        icu_data[M32R_IRQ_SIO0_R].icucr = 0;
        disable_mappi_irq(M32R_IRQ_SIO0_R);
@@ -112,7 +112,7 @@ void __init init_IRQ(void)
        /* SIO0_S : uart send data */
        irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED;
        irq_desc[M32R_IRQ_SIO0_S].chip = &mappi_irq_type;
-       irq_desc[M32R_IRQ_SIO0_S].action = 0;
+       irq_desc[M32R_IRQ_SIO0_S].action = NULL;
        irq_desc[M32R_IRQ_SIO0_S].depth = 1;
        icu_data[M32R_IRQ_SIO0_S].icucr = 0;
        disable_mappi_irq(M32R_IRQ_SIO0_S);
@@ -120,7 +120,7 @@ void __init init_IRQ(void)
        /* SIO1_R : uart receive data */
        irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED;
        irq_desc[M32R_IRQ_SIO1_R].chip = &mappi_irq_type;
-       irq_desc[M32R_IRQ_SIO1_R].action = 0;
+       irq_desc[M32R_IRQ_SIO1_R].action = NULL;
        irq_desc[M32R_IRQ_SIO1_R].depth = 1;
        icu_data[M32R_IRQ_SIO1_R].icucr = 0;
        disable_mappi_irq(M32R_IRQ_SIO1_R);
@@ -128,7 +128,7 @@ void __init init_IRQ(void)
        /* SIO1_S : uart send data */
        irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED;
        irq_desc[M32R_IRQ_SIO1_S].chip = &mappi_irq_type;
-       irq_desc[M32R_IRQ_SIO1_S].action = 0;
+       irq_desc[M32R_IRQ_SIO1_S].action = NULL;
        irq_desc[M32R_IRQ_SIO1_S].depth = 1;
        icu_data[M32R_IRQ_SIO1_S].icucr = 0;
        disable_mappi_irq(M32R_IRQ_SIO1_S);
@@ -138,7 +138,7 @@ void __init init_IRQ(void)
        /* INT1 : pccard0 interrupt */
        irq_desc[M32R_IRQ_INT1].status = IRQ_DISABLED;
        irq_desc[M32R_IRQ_INT1].chip = &mappi_irq_type;
-       irq_desc[M32R_IRQ_INT1].action = 0;
+       irq_desc[M32R_IRQ_INT1].action = NULL;
        irq_desc[M32R_IRQ_INT1].depth = 1;
        icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_IEN | M32R_ICUCR_ISMOD00;
        disable_mappi_irq(M32R_IRQ_INT1);
@@ -146,7 +146,7 @@ void __init init_IRQ(void)
        /* INT2 : pccard1 interrupt */
        irq_desc[M32R_IRQ_INT2].status = IRQ_DISABLED;
        irq_desc[M32R_IRQ_INT2].chip = &mappi_irq_type;
-       irq_desc[M32R_IRQ_INT2].action = 0;
+       irq_desc[M32R_IRQ_INT2].action = NULL;
        irq_desc[M32R_IRQ_INT2].depth = 1;
        icu_data[M32R_IRQ_INT2].icucr = M32R_ICUCR_IEN | M32R_ICUCR_ISMOD00;
        disable_mappi_irq(M32R_IRQ_INT2);
index a9174ef..b60cea4 100644 (file)
@@ -33,7 +33,7 @@
 int do_signal(struct pt_regs *, sigset_t *);
 
 asmlinkage int
-sys_rt_sigsuspend(sigset_t *unewset, size_t sigsetsize,
+sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize,
                  unsigned long r2, unsigned long r3, unsigned long r4,
                  unsigned long r5, unsigned long r6, struct pt_regs *regs)
 {
@@ -78,8 +78,8 @@ sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
 struct rt_sigframe
 {
        int sig;
-       struct siginfo *pinfo;
-       void *puc;
+       struct siginfo __user *pinfo;
+       void __user *puc;
        struct siginfo info;
        struct ucontext uc;
 //     struct _fpstate fpstate;
index 722e21f..3601291 100644 (file)
@@ -231,7 +231,7 @@ void smp_flush_tlb_all(void)
        local_irq_save(flags);
        __flush_tlb_all();
        local_irq_restore(flags);
-       smp_call_function(flush_tlb_all_ipi, 0, 1, 1);
+       smp_call_function(flush_tlb_all_ipi, NULL, 1, 1);
        preempt_enable();
 }
 
index b567351..b4e7bcb 100644 (file)
@@ -31,7 +31,7 @@
 /*
  * sys_tas() - test-and-set
  */
-asmlinkage int sys_tas(int *addr)
+asmlinkage int sys_tas(int __user *addr)
 {
        int oldval;
 
@@ -90,7 +90,7 @@ sys_pipe(unsigned long r0, unsigned long r1, unsigned long r2,
 
        error = do_pipe(fd);
        if (!error) {
-               if (copy_to_user((void *)r0, (void *)fd, 2*sizeof(int)))
+               if (copy_to_user((void __user *)r0, fd, 2*sizeof(int)))
                        error = -EFAULT;
        }
        return error;
@@ -201,7 +201,7 @@ asmlinkage int sys_ipc(uint call, int first, int second,
        }
 }
 
-asmlinkage int sys_uname(struct old_utsname * name)
+asmlinkage int sys_uname(struct old_utsname __user * name)
 {
        int err;
        if (!name)
index c1daf2c..97e0b1c 100644 (file)
@@ -268,7 +268,7 @@ static __inline__ void do_trap(int trapnr, int signr, const char * str,
 #define DO_ERROR(trapnr, signr, str, name) \
 asmlinkage void do_##name(struct pt_regs * regs, long error_code) \
 { \
-       do_trap(trapnr, signr, 0, regs, error_code, NULL); \
+       do_trap(trapnr, signr, NULL, regs, error_code, NULL); \
 }
 
 #define DO_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \
index f9636e8..6fc69c7 100644 (file)
@@ -1,61 +1,10 @@
 #include <linux/module.h>
-#include <linux/linkage.h>
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <linux/user.h>
-#include <linux/elfcore.h>
-#include <linux/in6.h>
-#include <linux/interrupt.h>
-
-#include <asm/setup.h>
-#include <asm/machdep.h>
-#include <asm/pgalloc.h>
-#include <asm/irq.h>
-#include <asm/io.h>
 #include <asm/semaphore.h>
-#include <asm/checksum.h>
 
 asmlinkage long long __ashldi3 (long long, int);
 asmlinkage long long __ashrdi3 (long long, int);
 asmlinkage long long __lshrdi3 (long long, int);
 asmlinkage long long __muldi3 (long long, long long);
-extern char m68k_debug_device[];
-
-/* platform dependent support */
-
-EXPORT_SYMBOL(m68k_machtype);
-EXPORT_SYMBOL(m68k_cputype);
-EXPORT_SYMBOL(m68k_is040or060);
-EXPORT_SYMBOL(m68k_realnum_memory);
-EXPORT_SYMBOL(m68k_memory);
-#ifndef CONFIG_SUN3
-EXPORT_SYMBOL(cache_push);
-EXPORT_SYMBOL(cache_clear);
-#ifndef CONFIG_SINGLE_MEMORY_CHUNK
-EXPORT_SYMBOL(mm_vtop);
-EXPORT_SYMBOL(mm_ptov);
-EXPORT_SYMBOL(mm_end_of_chunk);
-#else
-EXPORT_SYMBOL(m68k_memoffset);
-#endif /* !CONFIG_SINGLE_MEMORY_CHUNK */
-EXPORT_SYMBOL(__ioremap);
-EXPORT_SYMBOL(iounmap);
-EXPORT_SYMBOL(kernel_set_cachemode);
-#endif /* !CONFIG_SUN3 */
-EXPORT_SYMBOL(m68k_debug_device);
-EXPORT_SYMBOL(mach_hwclk);
-EXPORT_SYMBOL(mach_get_ss);
-EXPORT_SYMBOL(mach_get_rtc_pll);
-EXPORT_SYMBOL(mach_set_rtc_pll);
-#ifdef CONFIG_INPUT_M68K_BEEP_MODULE
-EXPORT_SYMBOL(mach_beep);
-#endif
-EXPORT_SYMBOL(dump_fpu);
-EXPORT_SYMBOL(dump_thread);
-EXPORT_SYMBOL(kernel_thread);
-#ifdef CONFIG_VME
-EXPORT_SYMBOL(vme_brdtype);
-#endif
 
 /* The following are special because they're not called
    explicitly (the C compiler generates them).  Fortunately,
index 45a4664..99fc122 100644 (file)
@@ -187,6 +187,7 @@ int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
        set_fs (fs);
        return pid;
 }
+EXPORT_SYMBOL(kernel_thread);
 
 void flush_thread(void)
 {
@@ -221,13 +222,13 @@ asmlinkage int m68k_clone(struct pt_regs *regs)
 {
        unsigned long clone_flags;
        unsigned long newsp;
-       int *parent_tidptr, *child_tidptr;
+       int __user *parent_tidptr, *child_tidptr;
 
        /* syscall2 puts clone_flags in d1 and usp in d2 */
        clone_flags = regs->d1;
        newsp = regs->d2;
-       parent_tidptr = (int *)regs->d3;
-       child_tidptr = (int *)regs->d4;
+       parent_tidptr = (int __user *)regs->d3;
+       child_tidptr = (int __user *)regs->d4;
        if (!newsp)
                newsp = rdusp();
        return do_fork(clone_flags, newsp, regs, 0,
@@ -311,6 +312,7 @@ int dump_fpu (struct pt_regs *regs, struct user_m68kfp_struct *fpu)
                : "memory");
        return 1;
 }
+EXPORT_SYMBOL(dump_fpu);
 
 /*
  * fill in the user structure for a core dump..
@@ -357,11 +359,12 @@ void dump_thread(struct pt_regs * regs, struct user * dump)
        /* dump floating point stuff */
        dump->u_fpvalid = dump_fpu (regs, &dump->m68kfp);
 }
+EXPORT_SYMBOL(dump_thread);
 
 /*
  * sys_execve() executes a new program.
  */
-asmlinkage int sys_execve(char *name, char **argv, char **envp)
+asmlinkage int sys_execve(char __user *name, char __user * __user *argv, char __user * __user *envp)
 {
        int error;
        char * filename;
index 42d5b85..9af3ee0 100644 (file)
 
 unsigned long m68k_machtype;
 unsigned long m68k_cputype;
+EXPORT_SYMBOL(m68k_machtype);
+EXPORT_SYMBOL(m68k_cputype);
 unsigned long m68k_fputype;
 unsigned long m68k_mmutype;
 #ifdef CONFIG_VME
 unsigned long vme_brdtype;
+EXPORT_SYMBOL(vme_brdtype);
 #endif
 
 int m68k_is040or060;
+EXPORT_SYMBOL(m68k_is040or060);
 
 extern int end;
 extern unsigned long availmem;
 
 int m68k_num_memory;
 int m68k_realnum_memory;
+EXPORT_SYMBOL(m68k_realnum_memory);
+#ifdef CONFIG_SINGLE_MEMORY_CHUNK
 unsigned long m68k_memoffset;
+EXPORT_SYMBOL(m68k_memoffset);
+#endif
 struct mem_info m68k_memory[NUM_MEMINFO];
+EXPORT_SYMBOL(m68k_memory);
 
 static struct mem_info m68k_ramdisk;
 
 static char m68k_command_line[CL_SIZE];
 
 char m68k_debug_device[6] = "";
+EXPORT_SYMBOL(m68k_debug_device);
 
 void (*mach_sched_init) (irq_handler_t handler) __initdata = NULL;
 /* machine dependent irq functions */
@@ -72,10 +82,14 @@ int (*mach_get_hardware_list) (char *buffer);
 /* machine dependent timer functions */
 unsigned long (*mach_gettimeoffset) (void);
 int (*mach_hwclk) (int, struct rtc_time*);
+EXPORT_SYMBOL(mach_hwclk);
 int (*mach_set_clock_mmss) (unsigned long);
 unsigned int (*mach_get_ss)(void);
 int (*mach_get_rtc_pll)(struct rtc_pll_info *);
 int (*mach_set_rtc_pll)(struct rtc_pll_info *);
+EXPORT_SYMBOL(mach_get_ss);
+EXPORT_SYMBOL(mach_get_rtc_pll);
+EXPORT_SYMBOL(mach_set_rtc_pll);
 void (*mach_reset)( void );
 void (*mach_halt)( void );
 void (*mach_power_off)( void );
@@ -89,6 +103,7 @@ void (*mach_l2_flush) (int);
 #endif
 #if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
 void (*mach_beep)(unsigned int, unsigned int);
+EXPORT_SYMBOL(mach_beep);
 #endif
 #if defined(CONFIG_ISA) && defined(MULTI_ISA)
 int isa_type;
index 4569406..759fa24 100644 (file)
@@ -326,13 +326,13 @@ static inline int do_040writeback1(unsigned short wbs, unsigned long wba,
 
        switch (wbs & WBSIZ_040) {
        case BA_SIZE_BYTE:
-               res = put_user(wbd & 0xff, (char *)wba);
+               res = put_user(wbd & 0xff, (char __user *)wba);
                break;
        case BA_SIZE_WORD:
-               res = put_user(wbd & 0xffff, (short *)wba);
+               res = put_user(wbd & 0xffff, (short __user *)wba);
                break;
        case BA_SIZE_LONG:
-               res = put_user(wbd, (int *)wba);
+               res = put_user(wbd, (int __user *)wba);
                break;
        }
 
index f46f049..b54ef17 100644 (file)
@@ -7,6 +7,7 @@
  *          used by other architectures                /Roman Zippel
  */
 
+#include <linux/module.h>
 #include <linux/mm.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
@@ -219,6 +220,7 @@ void __iomem *__ioremap(unsigned long physaddr, unsigned long size, int cachefla
 
        return (void __iomem *)retaddr;
 }
+EXPORT_SYMBOL(__ioremap);
 
 /*
  * Unmap a ioremap()ed region again
@@ -234,6 +236,7 @@ void iounmap(void __iomem *addr)
        free_io_area((__force void *)addr);
 #endif
 }
+EXPORT_SYMBOL(iounmap);
 
 /*
  * __iounmap unmaps nearly everything, so be careful
@@ -360,3 +363,4 @@ void kernel_set_cachemode(void *addr, unsigned long size, int cmode)
 
        flush_tlb_all();
 }
+EXPORT_SYMBOL(kernel_set_cachemode);
index a0c095e..0f88812 100644 (file)
@@ -4,6 +4,7 @@
  *  Copyright (C) 1995  Hamish Macdonald
  */
 
+#include <linux/module.h>
 #include <linux/mm.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
@@ -157,9 +158,8 @@ unsigned long mm_vtop(unsigned long vaddr)
 
        return -1;
 }
-#endif
+EXPORT_SYMBOL(mm_vtop);
 
-#ifndef CONFIG_SINGLE_MEMORY_CHUNK
 unsigned long mm_ptov (unsigned long paddr)
 {
        int i = 0;
@@ -185,6 +185,7 @@ unsigned long mm_ptov (unsigned long paddr)
 #endif
        return -1;
 }
+EXPORT_SYMBOL(mm_ptov);
 #endif
 
 /* invalidate page in both caches */
@@ -298,6 +299,7 @@ void cache_clear (unsigned long paddr, int len)
        mach_l2_flush(0);
 #endif
 }
+EXPORT_SYMBOL(cache_clear);    /* probably can be unexported */
 
 
 /*
@@ -350,6 +352,7 @@ void cache_push (unsigned long paddr, int len)
        mach_l2_flush(1);
 #endif
 }
+EXPORT_SYMBOL(cache_push);     /* probably can be unexported */
 
 #ifndef CONFIG_SINGLE_MEMORY_CHUNK
 int mm_end_of_chunk (unsigned long addr, int len)
@@ -361,4 +364,5 @@ int mm_end_of_chunk (unsigned long addr, int len)
                        return 1;
        return 0;
 }
+EXPORT_SYMBOL(mm_end_of_chunk);
 #endif
index 7f0d86f..1af24cb 100644 (file)
@@ -8,6 +8,7 @@
  * for more details.
  */
 
+#include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
@@ -59,7 +60,7 @@ static inline void do_pmeg_mapin(unsigned long phys, unsigned long virt,
        }
 }
 
-void *sun3_ioremap(unsigned long phys, unsigned long size,
+void __iomem *sun3_ioremap(unsigned long phys, unsigned long size,
                   unsigned long type)
 {
        struct vm_struct *area;
@@ -101,22 +102,24 @@ void *sun3_ioremap(unsigned long phys, unsigned long size,
                virt += seg_pages * PAGE_SIZE;
        }
 
-       return (void *)ret;
+       return (void __iomem *)ret;
 
 }
 
 
-void *__ioremap(unsigned long phys, unsigned long size, int cache)
+void __iomem *__ioremap(unsigned long phys, unsigned long size, int cache)
 {
 
        return sun3_ioremap(phys, size, SUN3_PAGE_TYPE_IO);
 
 }
+EXPORT_SYMBOL(__ioremap);
 
-void iounmap(void *addr)
+void iounmap(void __iomem *addr)
 {
        vfree((void *)(PAGE_MASK & (unsigned long)addr));
 }
+EXPORT_SYMBOL(iounmap);
 
 /* sun3_map_test(addr, val) -- Reads a byte from addr, storing to val,
  * trapping the potential read fault.  Returns 0 if the access faulted,
index 4d4f069..be1a847 100644 (file)
@@ -2,6 +2,6 @@
 # Makefile for Linux arch/m68k/sun3 source directory
 #
 
-obj-y  := sun3_ksyms.o sun3ints.o sun3dvma.o sbus.o idprom.o
+obj-y  := sun3ints.o sun3dvma.o sbus.o idprom.o
 
 obj-$(CONFIG_SUN3) += config.o mmu_emu.o leds.o dvma.o intersil.o
index 02c1fee..dca6ab6 100644 (file)
@@ -6,6 +6,7 @@
  * Sun3/3x models added by David Monro (davidm@psrg.cs.usyd.edu.au)
  */
 
+#include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/init.h>
@@ -16,6 +17,8 @@
 #include <asm/machines.h>  /* Fun with Sun released architectures. */
 
 struct idprom *idprom;
+EXPORT_SYMBOL(idprom);
+
 static struct idprom idprom_buffer;
 
 /* Here is the master table of Sun machines which use some implementation
diff --git a/arch/m68k/sun3/sun3_ksyms.c b/arch/m68k/sun3/sun3_ksyms.c
deleted file mode 100644 (file)
index 43e5a9a..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <linux/module.h>
-#include <linux/types.h>
-#include <asm/dvma.h>
-#include <asm/idprom.h>
-
-/*
- * Add things here when you find the need for it.
- */
-EXPORT_SYMBOL(dvma_map_align);
-EXPORT_SYMBOL(dvma_unmap);
-EXPORT_SYMBOL(dvma_malloc_align);
-EXPORT_SYMBOL(dvma_free);
-EXPORT_SYMBOL(idprom);
index a2bc2da..8709677 100644 (file)
@@ -6,6 +6,7 @@
  * Contains common routines for sun3/sun3x DVMA management.
  */
 
+#include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/list.h>
@@ -312,6 +313,7 @@ inline unsigned long dvma_map_align(unsigned long kaddr, int len, int align)
        BUG();
        return 0;
 }
+EXPORT_SYMBOL(dvma_map_align);
 
 void dvma_unmap(void *baddr)
 {
@@ -327,7 +329,7 @@ void dvma_unmap(void *baddr)
        return;
 
 }
-
+EXPORT_SYMBOL(dvma_unmap);
 
 void *dvma_malloc_align(unsigned long len, unsigned long align)
 {
@@ -367,6 +369,7 @@ void *dvma_malloc_align(unsigned long len, unsigned long align)
        return (void *)vaddr;
 
 }
+EXPORT_SYMBOL(dvma_malloc_align);
 
 void dvma_free(void *vaddr)
 {
@@ -374,3 +377,4 @@ void dvma_free(void *vaddr)
        return;
 
 }
+EXPORT_SYMBOL(dvma_free);
index 6d57553..8f6a0b3 100644 (file)
@@ -69,10 +69,6 @@ EXPORT_SYMBOL(memcpy_toio);
 EXPORT_SYMBOL(memcpy_fromio);
 EXPORT_SYMBOL(memset_io);
 
-#include <asm/unistd.h>
-EXPORT_SYMBOL(sys_lseek);
-EXPORT_SYMBOL(sys_write);
-
 #include <asm/semaphore.h>
 EXPORT_SYMBOL(__up);
 EXPORT_SYMBOL(__down_interruptible);
index 16fe027..d1c0758 100644 (file)
@@ -307,11 +307,12 @@ void __init paging_init(void)
               top_of_ram, total_ram);
        printk(KERN_DEBUG "Memory hole size: %ldMB\n",
               (top_of_ram - total_ram) >> 20);
+       memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 #ifdef CONFIG_HIGHMEM
-       max_zone_pfns[0] = total_lowmem >> PAGE_SHIFT;
-       max_zone_pfns[1] = top_of_ram >> PAGE_SHIFT;
+       max_zone_pfns[ZONE_DMA] = total_lowmem >> PAGE_SHIFT;
+       max_zone_pfns[ZONE_HIGHMEM] = top_of_ram >> PAGE_SHIFT;
 #else
-       max_zone_pfns[0] = top_of_ram >> PAGE_SHIFT;
+       max_zone_pfns[ZONE_DMA] = top_of_ram >> PAGE_SHIFT;
 #endif
        free_area_init_nodes(max_zone_pfns);
 }
index 43c2720..9da01dc 100644 (file)
@@ -617,9 +617,9 @@ void __init do_init_bootmem(void)
 
 void __init paging_init(void)
 {
-       unsigned long max_zone_pfns[MAX_NR_ZONES] = {
-                               lmb_end_of_DRAM() >> PAGE_SHIFT
-       };
+       unsigned long max_zone_pfns[MAX_NR_ZONES];
+       memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+       max_zone_pfns[ZONE_DMA] = lmb_end_of_DRAM() >> PAGE_SHIFT;
        free_area_init_nodes(max_zone_pfns);
 }
 
index 4102000..c374e53 100644 (file)
@@ -374,11 +374,12 @@ void __init paging_init(void)
        end_pfn = start_pfn + (total_memory >> PAGE_SHIFT);
        add_active_range(0, start_pfn, end_pfn);
 
+       memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 #ifdef CONFIG_HIGHMEM
-       max_zone_pfns[0] = total_lowmem >> PAGE_SHIFT;
-       max_zone_pfns[1] = total_memory >> PAGE_SHIFT;
+       max_zone_pfns[ZONE_DMA] = total_lowmem >> PAGE_SHIFT;
+       max_zone_pfns[ZONE_HIGHMEM] = total_memory >> PAGE_SHIFT;
 #else
-       max_zone_pfns[0] = total_memory >> PAGE_SHIFT;
+       max_zone_pfns[ZONE_DMA] = total_memory >> PAGE_SHIFT;
 #endif /* CONFIG_HIGHMEM */
        free_area_init_nodes(max_zone_pfns);
 }
index 9f19e83..90b5ef5 100644 (file)
@@ -51,4 +51,3 @@ EXPORT_SYMBOL(csum_fold);
 EXPORT_SYMBOL(console_mode);
 EXPORT_SYMBOL(console_devno);
 EXPORT_SYMBOL(console_irq);
-EXPORT_SYMBOL(sys_wait4);
index d753075..78fb619 100644 (file)
@@ -25,6 +25,19 @@ config PCI
 config PCMCIA
        bool
 
+# Yet to do!
+config TRACE_IRQFLAGS_SUPPORT
+       bool
+       default n
+
+config LOCKDEP_SUPPORT
+       bool
+       default y
+
+config STACKTRACE_SUPPORT
+       bool
+       default y
+
 config GENERIC_CALIBRATE_DELAY
        bool
        default y
@@ -37,13 +50,15 @@ config IRQ_RELEASE_METHOD
 menu "UML-specific options"
 
 config MODE_TT
-       bool "Tracing thread support"
+       bool "Tracing thread support (DEPRECATED)"
        default n
        help
        This option controls whether tracing thread support is compiled
-       into UML.  This option is largely obsolete, given that skas0 provides
+       into UML. This option is largely obsolete, given that skas0 provides
        skas security and performance without needing to patch the host.
-       It is safe to say 'N' here.
+       It is safe to say 'N' here; saying 'Y' may cause additional problems
+       with the resulting binary even if you run UML in SKAS mode, and running
+       in TT mode is strongly *NOT RECOMMENDED*.
 
 config STATIC_LINK
        bool "Force a static link"
@@ -56,6 +71,9 @@ config STATIC_LINK
        for use in a chroot jail.  So, if you intend to run UML inside a
        chroot, and you disable CONFIG_MODE_TT, you probably want to say Y
        here.
+       Additionally, this option enables using higher memory spaces (up to
+       2.75G) for UML - disabling CONFIG_MODE_TT and enabling this option leads
+       to best results for this.
 
 config KERNEL_HALF_GIGS
        int "Kernel address space size (in .5G units)"
@@ -72,10 +90,13 @@ config MODE_SKAS
        default y
        help
        This option controls whether skas (separate kernel address space)
-       support is compiled in.  If you have applied the skas patch to the
-       host, then you certainly want to say Y here (and consider saying N
-       to CONFIG_MODE_TT).  Otherwise, it is safe to say Y.  Disabling this
-       option will shrink the UML binary slightly.
+       support is compiled in.
+       Unless you have specific needs to use TT mode (which applies almost only
+       to developers), you should say Y here.
+       SKAS mode will make use of the SKAS3 patch if it is applied on the host
+       (and your UML will run in SKAS3 mode), but if no SKAS patch is applied
+       on the host it will run in SKAS0 mode, which is anyway faster than TT
+       mode.
 
 source "arch/um/Kconfig.arch"
 source "mm/Kconfig"
index f6eb72d..f191a55 100644 (file)
@@ -16,23 +16,42 @@ config SEMAPHORE_SLEEPERS
        bool
        default y
 
-config HOST_2G_2G
-       bool "2G/2G host address space split"
-       default n
-       help
-       This is needed when the host on which you run has a 2G/2G memory
-       split, instead of the customary 3G/1G.
-
-       Note that to enable such a host
-       configuration, which makes sense only in some cases, you need special
-       host patches.
-
-       So, if you do not know what to do here, say 'N'.
+choice
+       prompt "Host memory split"
+       default HOST_VMSPLIT_3G
+       ---help---
+          This is needed when the host kernel on which you run has a non-default
+          (like 2G/2G) memory split, instead of the customary 3G/1G. If you did
+          not recompile your own kernel but use the default distro's one, you can
+          safely accept the "Default split" option.
+
+          It can be enabled on recent (>=2.6.16-rc2) vanilla kernels via
+          CONFIG_VM_SPLIT_*, or on previous kernels with special patches (-ck
+          patchset by Con Kolivas, or other ones) - option names match closely the
+          host CONFIG_VM_SPLIT_* ones.
+
+          A lower setting (where 1G/3G is lowest and 3G/1G is higher) will
+          tolerate even more "normal" host kernels, but an higher setting will be
+          stricter.
+
+          So, if you do not know what to do here, say 'Default split'.
+
+       config HOST_VMSPLIT_3G
+               bool "Default split (3G/1G user/kernel host split)"
+       config HOST_VMSPLIT_3G_OPT
+               bool "3G/1G user/kernel host split (for full 1G low memory)"
+       config HOST_VMSPLIT_2G
+               bool "2G/2G user/kernel host split"
+       config HOST_VMSPLIT_1G
+               bool "1G/3G user/kernel host split"
+endchoice
 
 config TOP_ADDR
-       hex
-       default 0xc0000000 if !HOST_2G_2G
-       default 0x80000000 if HOST_2G_2G
+       hex
+       default 0xB0000000 if HOST_VMSPLIT_3G_OPT
+       default 0x78000000 if HOST_VMSPLIT_2G
+       default 0x40000000 if HOST_VMSPLIT_1G
+       default 0xC0000000
 
 config 3_LEVEL_PGTABLES
        bool "Three-level pagetables (EXPERIMENTAL)"
index 11154b6..d278682 100644 (file)
@@ -1,10 +1,10 @@
 # Copyright 2003 - 2004 Pathscale, Inc
 # Released under the GPL
 
-core-y += arch/um/sys-x86_64/
+core-y += arch/um/sys-x86_64/ arch/x86_64/crypto/
 START := 0x60000000
 
-_extra_flags_ = -fno-builtin -m64 -mcmodel=kernel
+_extra_flags_ = -fno-builtin -m64
 
 #We #undef __x86_64__ for kernelspace, not for userspace where
 #it's needed for headers to work!
index 356390d..461175f 100644 (file)
@@ -1,9 +1,16 @@
 /* for use by sys-$SUBARCH/kernel-offsets.c */
 
+DEFINE(KERNEL_MADV_REMOVE, MADV_REMOVE);
+#ifdef CONFIG_MODE_TT
+OFFSET(HOST_TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid);
+#endif
+
 OFFSET(HOST_TASK_REGS, task_struct, thread.regs);
 OFFSET(HOST_TASK_PID, task_struct, pid);
+
 DEFINE(UM_KERN_PAGE_SIZE, PAGE_SIZE);
 DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC);
+
 DEFINE_STR(UM_KERN_EMERG, KERN_EMERG);
 DEFINE_STR(UM_KERN_ALERT, KERN_ALERT);
 DEFINE_STR(UM_KERN_CRIT, KERN_CRIT);
@@ -12,6 +19,10 @@ DEFINE_STR(UM_KERN_WARNING, KERN_WARNING);
 DEFINE_STR(UM_KERN_NOTICE, KERN_NOTICE);
 DEFINE_STR(UM_KERN_INFO, KERN_INFO);
 DEFINE_STR(UM_KERN_DEBUG, KERN_DEBUG);
+
 DEFINE(UM_ELF_CLASS, ELF_CLASS);
 DEFINE(UM_ELFCLASS32, ELFCLASS32);
 DEFINE(UM_ELFCLASS64, ELFCLASS64);
+
+/* For crypto assembler code. */
+DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx));
index e93c6d3..e860bc5 100644 (file)
@@ -12,7 +12,8 @@ extern void longjmp(jmp_buf, int);
 } while(0)
 
 #define UML_SETJMP(buf) ({ \
-       int n, enable;     \
+       int n;     \
+       volatile int enable;    \
        enable = get_signals(); \
        n = setjmp(*buf); \
        if(n != 0) \
index 120ca21..6516f6d 100644 (file)
@@ -201,6 +201,7 @@ extern int os_getpgrp(void);
 
 #ifdef UML_CONFIG_MODE_TT
 extern void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int));
+extern void stop(void);
 #endif
 extern void init_new_thread_signals(void);
 extern int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr);
index 2c13de3..97ec9d8 100644 (file)
@@ -1,6 +1,7 @@
 #include <linux/stddef.h>
 #include <linux/sched.h>
 #include <linux/elf.h>
+#include <linux/crypto.h>
 #include <asm/mman.h>
 
 #define DEFINE(sym, val) \
@@ -17,9 +18,5 @@
 void foo(void)
 {
        OFFSET(HOST_TASK_DEBUGREGS, task_struct, thread.arch.debugregs);
-       DEFINE(KERNEL_MADV_REMOVE, MADV_REMOVE);
-#ifdef CONFIG_MODE_TT
-       OFFSET(HOST_TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid);
-#endif
 #include <common-offsets.h>
 }
index 91d129f..a307237 100644 (file)
@@ -2,6 +2,7 @@
 #include <linux/sched.h>
 #include <linux/time.h>
 #include <linux/elf.h>
+#include <linux/crypto.h>
 #include <asm/page.h>
 #include <asm/mman.h>
 
@@ -18,9 +19,5 @@
 
 void foo(void)
 {
-       DEFINE(KERNEL_MADV_REMOVE, MADV_REMOVE);
-#ifdef CONFIG_MODE_TT
-       OFFSET(HOST_TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid);
-#endif
 #include <common-offsets.h>
 }
index c17eddc..2c6d090 100644 (file)
@@ -60,10 +60,7 @@ static int init_stub_pte(struct mm_struct *mm, unsigned long proc,
 #endif
 
        *pte = mk_pte(virt_to_page(kernel), __pgprot(_PAGE_PRESENT));
-       /* This is wrong for the code page, but it doesn't matter since the
-        * stub is mapped by hand with the correct permissions.
-        */
-       *pte = pte_mkwrite(*pte);
+       *pte = pte_mkread(*pte);
        return(0);
 
  out_pmd:
index 6c92bbc..ed1abcf 100644 (file)
@@ -4,13 +4,13 @@
  * Licensed under the GPL
  */
 
-#include <setjmp.h>
 #include <string.h>
 #include "user_util.h"
 #include "uml_uaccess.h"
 #include "task.h"
 #include "kern_util.h"
 #include "os.h"
+#include "longjmp.h"
 
 int __do_copy_from_user(void *to, const void *from, int n,
                        void **fault_addr, void **fault_catcher)
@@ -80,10 +80,10 @@ int __do_strnlen_user(const char *str, unsigned long n,
        struct tt_regs save = TASK_REGS(get_current())->tt;
        int ret;
        unsigned long *faddrp = (unsigned long *)fault_addr;
-       sigjmp_buf jbuf;
+       jmp_buf jbuf;
 
        *fault_catcher = &jbuf;
-       if(sigsetjmp(jbuf, 1) == 0)
+       if(UML_SETJMP(&jbuf) == 0)
                ret = strlen(str) + 1;
        else ret = *faddrp - (unsigned long) str;
 
index 5461a06..3dc3a02 100644 (file)
@@ -10,7 +10,6 @@
 #include <errno.h>
 #include <stdarg.h>
 #include <stdlib.h>
-#include <setjmp.h>
 #include <sys/time.h>
 #include <sys/ptrace.h>
 #include <linux/ptrace.h>
index 3f5b151..56b8a50 100644 (file)
@@ -80,11 +80,18 @@ void setup_machinename(char *machine_out)
        struct utsname host;
 
        uname(&host);
-#if defined(UML_CONFIG_UML_X86) && !defined(UML_CONFIG_64BIT)
+#ifdef UML_CONFIG_UML_X86
+# ifndef UML_CONFIG_64BIT
        if (!strcmp(host.machine, "x86_64")) {
                strcpy(machine_out, "i686");
                return;
        }
+# else
+       if (!strcmp(host.machine, "i686")) {
+               strcpy(machine_out, "x86_64");
+               return;
+       }
+# endif
 #endif
        strcpy(machine_out, host.machine);
 }
index 8592738..12c5936 100644 (file)
@@ -14,6 +14,3 @@ EXPORT_SYMBOL(__up_wakeup);
 
 /*XXX: we need them because they would be exported by x86_64 */
 EXPORT_SYMBOL(__memcpy);
-
-/* Networking helper routines. */
-EXPORT_SYMBOL(ip_compute_csum);
index 771bcf7..c3cdcab 100644 (file)
@@ -1897,7 +1897,7 @@ static void set_ht_irq_affinity(unsigned int irq, cpumask_t mask)
 }
 #endif
 
-static struct hw_interrupt_type ht_irq_chip = {
+static struct irq_chip ht_irq_chip = {
        .name           = "PCI-HT",
        .mask           = mask_ht_irq,
        .unmask         = unmask_ht_irq,
index 19c7252..971dc11 100644 (file)
@@ -406,9 +406,12 @@ void __cpuinit zap_low_mappings(int cpu)
 #ifndef CONFIG_NUMA
 void __init paging_init(void)
 {
-       unsigned long max_zone_pfns[MAX_NR_ZONES] = {MAX_DMA_PFN,
-                                                       MAX_DMA32_PFN,
-                                                       end_pfn};
+       unsigned long max_zone_pfns[MAX_NR_ZONES];
+       memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+       max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN;
+       max_zone_pfns[ZONE_DMA32] = MAX_DMA32_PFN;
+       max_zone_pfns[ZONE_NORMAL] = end_pfn;
+
        memory_present(0, 0, end_pfn);
        sparse_init();
        free_area_init_nodes(max_zone_pfns);
index 829a008..2ee2e00 100644 (file)
@@ -338,9 +338,11 @@ static void __init arch_sparse_init(void)
 void __init paging_init(void)
 { 
        int i;
-       unsigned long max_zone_pfns[MAX_NR_ZONES] = { MAX_DMA_PFN,
-               MAX_DMA32_PFN,
-               end_pfn};
+       unsigned long max_zone_pfns[MAX_NR_ZONES];
+       memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+       max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN;
+       max_zone_pfns[ZONE_DMA32] = MAX_DMA32_PFN;
+       max_zone_pfns[ZONE_NORMAL] = end_pfn;
 
        arch_sparse_init();
 
index cec539e..6148073 100644 (file)
@@ -4379,8 +4379,8 @@ static inline void DAC960_P_To_PD_TranslateEnquiry(void *Enquiry)
 static inline void DAC960_P_To_PD_TranslateDeviceState(void *DeviceState)
 {
   memcpy(DeviceState + 2, DeviceState + 3, 1);
-  memcpy(DeviceState + 4, DeviceState + 5, 2);
-  memcpy(DeviceState + 6, DeviceState + 8, 4);
+  memmove(DeviceState + 4, DeviceState + 5, 2);
+  memmove(DeviceState + 6, DeviceState + 8, 4);
 }
 
 static inline
index 5d254b7..5d65621 100644 (file)
@@ -1709,10 +1709,13 @@ static struct kobject *floppy_find(dev_t dev, int *part, void *data)
        return get_disk(unit[drive].gendisk);
 }
 
-int __init amiga_floppy_init(void)
+static int __init amiga_floppy_init(void)
 {
        int i, ret;
 
+       if (!MACH_IS_AMIGA)
+               return -ENXIO;
+
        if (!AMIGAHW_PRESENT(AMI_FLOPPY))
                return -ENXIO;
 
@@ -1809,15 +1812,9 @@ out_blkdev:
        return ret;
 }
 
+module_init(amiga_floppy_init);
 #ifdef MODULE
 
-int init_module(void)
-{
-       if (!MACH_IS_AMIGA)
-               return -ENXIO;
-       return amiga_floppy_init();
-}
-
 #if 0 /* not safe to unload */
 void cleanup_module(void)
 {
index 10cc387..0d97b7e 100644 (file)
@@ -48,9 +48,9 @@
 #include <linux/blkdev.h>
 #include <linux/blkpg.h>
 #include <linux/delay.h>
+#include <linux/io.h>
 
 #include <asm/system.h>
-#include <asm/io.h>
 #include <asm/uaccess.h>
 #include <asm/dma.h>
 
index 82ddbdd..7cc2685 100644 (file)
@@ -329,7 +329,7 @@ static struct kobject *z2_find(dev_t dev, int *part, void *data)
 
 static struct request_queue *z2_queue;
 
-int __init 
+static int __init 
 z2_init(void)
 {
     int ret;
@@ -370,26 +370,7 @@ err:
     return ret;
 }
 
-#if defined(MODULE)
-
-MODULE_LICENSE("GPL");
-
-int
-init_module( void )
-{
-    int error;
-    
-    error = z2_init();
-    if ( error == 0 )
-    {
-       printk( KERN_INFO DEVICE_NAME ": loaded as module\n" );
-    }
-    
-    return error;
-}
-
-void
-cleanup_module( void )
+static void __exit z2_exit(void)
 {
     int i, j;
     blk_unregister_region(MKDEV(Z2RAM_MAJOR, 0), 256);
@@ -425,4 +406,7 @@ cleanup_module( void )
 
     return;
 } 
-#endif
+
+module_init(z2_init);
+module_exit(z2_exit);
+MODULE_LICENSE("GPL");
index fc944d3..54d93f0 100644 (file)
@@ -1007,7 +1007,7 @@ i2InputAvailable(i2ChanStrPtr pCh)
 // applications that one cannot break out of.
 //******************************************************************************
 static int
-i2Output(i2ChanStrPtr pCh, const char *pSource, int count, int user )
+i2Output(i2ChanStrPtr pCh, const char *pSource, int count)
 {
        i2eBordStrPtr pB;
        unsigned char *pInsert;
@@ -1020,7 +1020,7 @@ i2Output(i2ChanStrPtr pCh, const char *pSource, int count, int user )
 
        int bailout = 10;
 
-       ip2trace (CHANN, ITRC_OUTPUT, ITRC_ENTER, 2, count, user );
+       ip2trace (CHANN, ITRC_OUTPUT, ITRC_ENTER, 2, count, 0 );
 
        // Ensure channel structure seems real
        if ( !i2Validate ( pCh ) ) 
@@ -1087,12 +1087,7 @@ i2Output(i2ChanStrPtr pCh, const char *pSource, int count, int user )
                        DATA_COUNT_OF(pInsert)  = amountToMove;
 
                        // Move the data
-                       if ( user ) {
-                               rc = copy_from_user((char*)(DATA_OF(pInsert)), pSource,
-                                               amountToMove );
-                       } else {
-                               memcpy( (char*)(DATA_OF(pInsert)), pSource, amountToMove );
-                       }
+                       memcpy( (char*)(DATA_OF(pInsert)), pSource, amountToMove );
                        // Adjust pointers and indices
                        pSource                                 += amountToMove;
                        pCh->Obuf_char_count    += amountToMove;
index 952e113..e559e9b 100644 (file)
@@ -332,7 +332,7 @@ static int  i2QueueCommands(int, i2ChanStrPtr, int, int, cmdSyntaxPtr,...);
 static int  i2GetStatus(i2ChanStrPtr, int);
 static int  i2Input(i2ChanStrPtr);
 static int  i2InputFlush(i2ChanStrPtr);
-static int  i2Output(i2ChanStrPtr, const char *, int, int);
+static int  i2Output(i2ChanStrPtr, const char *, int);
 static int  i2OutputFree(i2ChanStrPtr);
 static int  i2ServiceBoard(i2eBordStrPtr);
 static void i2DrainOutput(i2ChanStrPtr, int);
index 858ba54..a3f32d4 100644 (file)
@@ -1704,7 +1704,7 @@ ip2_write( PTTY tty, const unsigned char *pData, int count)
 
        /* This is the actual move bit. Make sure it does what we need!!!!! */
        WRITE_LOCK_IRQSAVE(&pCh->Pbuf_spinlock,flags);
-       bytesSent = i2Output( pCh, pData, count, 0 );
+       bytesSent = i2Output( pCh, pData, count);
        WRITE_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags);
 
        ip2trace (CHANN, ITRC_WRITE, ITRC_RETURN, 1, bytesSent );
@@ -1764,7 +1764,7 @@ ip2_flush_chars( PTTY tty )
                //
                // We may need to restart i2Output if it does not fullfill this request
                //
-               strip = i2Output( pCh, pCh->Pbuf, pCh->Pbuf_stuff, 0 );
+               strip = i2Output( pCh, pCh->Pbuf, pCh->Pbuf_stuff);
                if ( strip != pCh->Pbuf_stuff ) {
                        memmove( pCh->Pbuf, &pCh->Pbuf[strip], pCh->Pbuf_stuff - strip );
                }
index 2455e8d..34a4fd1 100644 (file)
@@ -1928,13 +1928,8 @@ static ssize_t guid_show(struct device *dev, struct device_attribute *attr,
                        (long long) bmc->guid[8]);
 }
 
-static void
-cleanup_bmc_device(struct kref *ref)
+static void remove_files(struct bmc_device *bmc)
 {
-       struct bmc_device *bmc;
-
-       bmc = container_of(ref, struct bmc_device, refcount);
-
        device_remove_file(&bmc->dev->dev,
                           &bmc->device_id_attr);
        device_remove_file(&bmc->dev->dev,
@@ -1951,12 +1946,23 @@ cleanup_bmc_device(struct kref *ref)
                           &bmc->manufacturer_id_attr);
        device_remove_file(&bmc->dev->dev,
                           &bmc->product_id_attr);
+
        if (bmc->id.aux_firmware_revision_set)
                device_remove_file(&bmc->dev->dev,
                                   &bmc->aux_firmware_rev_attr);
        if (bmc->guid_set)
                device_remove_file(&bmc->dev->dev,
                                   &bmc->guid_attr);
+}
+
+static void
+cleanup_bmc_device(struct kref *ref)
+{
+       struct bmc_device *bmc;
+
+       bmc = container_of(ref, struct bmc_device, refcount);
+
+       remove_files(bmc);
        platform_device_unregister(bmc->dev);
        kfree(bmc);
 }
@@ -1977,6 +1983,79 @@ static void ipmi_bmc_unregister(ipmi_smi_t intf)
        mutex_unlock(&ipmidriver_mutex);
 }
 
+static int create_files(struct bmc_device *bmc)
+{
+       int err;
+
+       err = device_create_file(&bmc->dev->dev,
+                          &bmc->device_id_attr);
+       if (err) goto out;
+       err = device_create_file(&bmc->dev->dev,
+                          &bmc->provides_dev_sdrs_attr);
+       if (err) goto out_devid;
+       err = device_create_file(&bmc->dev->dev,
+                          &bmc->revision_attr);
+       if (err) goto out_sdrs;
+       err = device_create_file(&bmc->dev->dev,
+                          &bmc->firmware_rev_attr);
+       if (err) goto out_rev;
+       err = device_create_file(&bmc->dev->dev,
+                          &bmc->version_attr);
+       if (err) goto out_firm;
+       err = device_create_file(&bmc->dev->dev,
+                          &bmc->add_dev_support_attr);
+       if (err) goto out_version;
+       err = device_create_file(&bmc->dev->dev,
+                          &bmc->manufacturer_id_attr);
+       if (err) goto out_add_dev;
+       err = device_create_file(&bmc->dev->dev,
+                          &bmc->product_id_attr);
+       if (err) goto out_manu;
+       if (bmc->id.aux_firmware_revision_set) {
+               err = device_create_file(&bmc->dev->dev,
+                                  &bmc->aux_firmware_rev_attr);
+               if (err) goto out_prod_id;
+       }
+       if (bmc->guid_set) {
+               err = device_create_file(&bmc->dev->dev,
+                                  &bmc->guid_attr);
+               if (err) goto out_aux_firm;
+       }
+
+       return 0;
+
+out_aux_firm:
+       if (bmc->id.aux_firmware_revision_set)
+               device_remove_file(&bmc->dev->dev,
+                                  &bmc->aux_firmware_rev_attr);
+out_prod_id:
+       device_remove_file(&bmc->dev->dev,
+                          &bmc->product_id_attr);
+out_manu:
+       device_remove_file(&bmc->dev->dev,
+                          &bmc->manufacturer_id_attr);
+out_add_dev:
+       device_remove_file(&bmc->dev->dev,
+                          &bmc->add_dev_support_attr);
+out_version:
+       device_remove_file(&bmc->dev->dev,
+                          &bmc->version_attr);
+out_firm:
+       device_remove_file(&bmc->dev->dev,
+                          &bmc->firmware_rev_attr);
+out_rev:
+       device_remove_file(&bmc->dev->dev,
+                          &bmc->revision_attr);
+out_sdrs:
+       device_remove_file(&bmc->dev->dev,
+                          &bmc->provides_dev_sdrs_attr);
+out_devid:
+       device_remove_file(&bmc->dev->dev,
+                          &bmc->device_id_attr);
+out:
+       return err;
+}
+
 static int ipmi_bmc_register(ipmi_smi_t intf)
 {
        int               rv;
@@ -2051,7 +2130,6 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
                bmc->provides_dev_sdrs_attr.attr.mode = S_IRUGO;
                bmc->provides_dev_sdrs_attr.show = provides_dev_sdrs_show;
 
-
                bmc->revision_attr.attr.name = "revision";
                bmc->revision_attr.attr.owner = THIS_MODULE;
                bmc->revision_attr.attr.mode = S_IRUGO;
@@ -2093,28 +2171,14 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
                bmc->aux_firmware_rev_attr.attr.mode = S_IRUGO;
                bmc->aux_firmware_rev_attr.show = aux_firmware_rev_show;
 
-               device_create_file(&bmc->dev->dev,
-                                  &bmc->device_id_attr);
-               device_create_file(&bmc->dev->dev,
-                                  &bmc->provides_dev_sdrs_attr);
-               device_create_file(&bmc->dev->dev,
-                                  &bmc->revision_attr);
-               device_create_file(&bmc->dev->dev,
-                                  &bmc->firmware_rev_attr);
-               device_create_file(&bmc->dev->dev,
-                                  &bmc->version_attr);
-               device_create_file(&bmc->dev->dev,
-                                  &bmc->add_dev_support_attr);
-               device_create_file(&bmc->dev->dev,
-                                  &bmc->manufacturer_id_attr);
-               device_create_file(&bmc->dev->dev,
-                                  &bmc->product_id_attr);
-               if (bmc->id.aux_firmware_revision_set)
-                       device_create_file(&bmc->dev->dev,
-                                          &bmc->aux_firmware_rev_attr);
-               if (bmc->guid_set)
-                       device_create_file(&bmc->dev->dev,
-                                          &bmc->guid_attr);
+               rv = create_files(bmc);
+               if (rv) {
+                       mutex_lock(&ipmidriver_mutex);
+                       platform_device_unregister(bmc->dev);
+                       mutex_unlock(&ipmidriver_mutex);
+
+                       return rv;
+               }
 
                printk(KERN_INFO
                       "ipmi: Found new BMC (man_id: 0x%6.6x, "
index a082a2e..6ad2d3b 100644 (file)
@@ -1153,7 +1153,14 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, const struct tpm_vend
 
        spin_unlock(&driver_lock);
 
-       sysfs_create_group(&dev->kobj, chip->vendor.attr_group);
+       if (sysfs_create_group(&dev->kobj, chip->vendor.attr_group)) {
+               list_del(&chip->list);
+               put_device(dev);
+               clear_bit(chip->dev_num, dev_mask);
+               kfree(chip);
+               kfree(devname);
+               return NULL;
+       }
 
        chip->bios_dir = tpm_bios_log_setup(devname);
 
index ad8ffe4..1ab0896 100644 (file)
@@ -184,7 +184,9 @@ static int __init init_atmel(void)
        unsigned long base;
        struct  tpm_chip *chip;
 
-       driver_register(&atml_drv);
+       rc = driver_register(&atml_drv);
+       if (rc)
+               return rc;
 
        if ((iobase = atmel_get_base_addr(&base, &region_size)) == NULL) {
                rc = -ENODEV;
@@ -195,10 +197,8 @@ static int __init init_atmel(void)
            (atmel_request_region
             (tpm_atmel.base, region_size, "tpm_atmel0") == NULL) ? 0 : 1;
 
-
-       if (IS_ERR
-           (pdev =
-            platform_device_register_simple("tpm_atmel", -1, NULL, 0))) {
+       pdev = platform_device_register_simple("tpm_atmel", -1, NULL, 0);
+       if (IS_ERR(pdev)) {
                rc = PTR_ERR(pdev);
                goto err_rel_reg;
        }
index 26287aa..608f730 100644 (file)
@@ -284,7 +284,7 @@ static struct device_driver nsc_drv = {
 static int __init init_nsc(void)
 {
        int rc = 0;
-       int lo, hi;
+       int lo, hi, err;
        int nscAddrBase = TPM_ADDR;
        struct tpm_chip *chip;
        unsigned long base;
@@ -297,7 +297,9 @@ static int __init init_nsc(void)
                        return -ENODEV;
        }
 
-       driver_register(&nsc_drv);
+       err = driver_register(&nsc_drv);
+       if (err)
+               return err;
 
        hi = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_HI);
        lo = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_LO);
index 3a365e1..d944647 100644 (file)
@@ -226,14 +226,26 @@ static int __init eisa_init_device (struct eisa_root_device *root,
 
 static int __init eisa_register_device (struct eisa_device *edev)
 {
-       if (device_register (&edev->dev))
-               return -1;
+       int rc = device_register (&edev->dev);
+       if (rc)
+               return rc;
 
-       device_create_file (&edev->dev, &dev_attr_signature);
-       device_create_file (&edev->dev, &dev_attr_enabled);
-       device_create_file (&edev->dev, &dev_attr_modalias);
+       rc = device_create_file (&edev->dev, &dev_attr_signature);
+       if (rc) goto err_devreg;
+       rc = device_create_file (&edev->dev, &dev_attr_enabled);
+       if (rc) goto err_sig;
+       rc = device_create_file (&edev->dev, &dev_attr_modalias);
+       if (rc) goto err_enab;
 
        return 0;
+
+err_enab:
+       device_remove_file (&edev->dev, &dev_attr_enabled);
+err_sig:
+       device_remove_file (&edev->dev, &dev_attr_signature);
+err_devreg:
+       device_unregister(&edev->dev);
+       return rc;
 }
 
 static int __init eisa_request_resources (struct eisa_root_device *root,
index fc17599..08b1617 100644 (file)
@@ -249,7 +249,7 @@ static int packetize_data(void *data, size_t length)
                if ((rc = create_packet(temp, packet_length)))
                        return rc;
 
-               pr_debug("%p:%lu\n", temp, (end - temp));
+               pr_debug("%p:%td\n", temp, (end - temp));
                temp += packet_length;
        }
 
@@ -718,14 +718,27 @@ static int __init dcdrbu_init(void)
                return -EIO;
        }
 
-       sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_data_attr);
-       sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_image_type_attr);
-       sysfs_create_bin_file(&rbu_device->dev.kobj,
+       rc = sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_data_attr);
+       if (rc)
+               goto out_devreg;
+       rc = sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_image_type_attr);
+       if (rc)
+               goto out_data;
+       rc = sysfs_create_bin_file(&rbu_device->dev.kobj,
                &rbu_packet_size_attr);
+       if (rc)
+               goto out_imtype;
 
        rbu_data.entry_created = 0;
-       return rc;
+       return 0;
 
+out_imtype:
+       sysfs_remove_bin_file(&rbu_device->dev.kobj, &rbu_image_type_attr);
+out_data:
+       sysfs_remove_bin_file(&rbu_device->dev.kobj, &rbu_data_attr);
+out_devreg:
+       platform_device_unregister(rbu_device);
+       return rc;
 }
 
 static __exit void dcdrbu_exit(void)
index 8ebce1c..5ab5e39 100644 (file)
@@ -639,7 +639,12 @@ efivar_create_sysfs_entry(unsigned long variable_name_size,
 
        kobject_set_name(&new_efivar->kobj, "%s", short_name);
        kobj_set_kset_s(new_efivar, vars_subsys);
-       kobject_register(&new_efivar->kobj);
+       i = kobject_register(&new_efivar->kobj);
+       if (i) {
+               kfree(short_name);
+               kfree(new_efivar);
+               return 1;
+       }
 
        kfree(short_name);
        short_name = NULL;
index 965c436..5b77a5b 100644 (file)
@@ -237,10 +237,12 @@ static int __devinit generic_init_one(struct pci_dev *dev, const struct pci_devi
        if (dev->vendor == PCI_VENDOR_ID_JMICRON && PCI_FUNC(dev->devfn) != 1)
                goto out;
 
-       pci_read_config_word(dev, PCI_COMMAND, &command);
-       if (!(command & PCI_COMMAND_IO)) {
-               printk(KERN_INFO "Skipping disabled %s IDE controller.\n", d->name);
-               goto out;
+       if (dev->vendor != PCI_VENDOR_ID_JMICRON) {
+               pci_read_config_word(dev, PCI_COMMAND, &command);
+               if (!(command & PCI_COMMAND_IO)) {
+                       printk(KERN_INFO "Skipping disabled %s IDE controller.\n", d->name);
+                       goto out;
+               }
        }
        ret = ide_setup_pci_device(dev, d);
 out:
index 4639537..7b9d1c1 100644 (file)
@@ -17,7 +17,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 59 Temple Place Suite 330, Boston, MA 02111-1307, USA.
  */
-#include <asm/io.h>
+#include <linux/io.h>
 #include <linux/dmi.h>
 #include <linux/init.h>
 #include <linux/input.h>
index 13e7d21..937fd21 100644 (file)
@@ -311,6 +311,7 @@ pcbit_deliver(void *data)
                dev->read_queue = frame->next;
                spin_unlock_irqrestore(&dev->lock, flags);
 
+               msg = 0;
                SET_MSG_CPU(msg, 0);
                SET_MSG_PROC(msg, 0);
                SET_MSG_CMD(msg, frame->skb->data[2]);
index 222ca7c..06c9872 100644 (file)
@@ -98,13 +98,14 @@ static int __init sc_init(void)
                         * Confirm the I/O Address with a test
                         */
                        if(io[b] == 0) {
-                               pr_debug("I/O Address 0x%x is in use.\n");
+                               pr_debug("I/O Address invalid.\n");
                                continue;
                        }
 
                        outb(0x18, io[b] + 0x400 * EXP_PAGE0);
                        if(inb(io[b] + 0x400 * EXP_PAGE0) != 0x18) {
-                               pr_debug("I/O Base 0x%x fails test\n");
+                               pr_debug("I/O Base 0x%x fails test\n",
+                                        io[b] + 0x400 * EXP_PAGE0);
                                continue;
                        }
                }
@@ -158,8 +159,8 @@ static int __init sc_init(void)
                        outb(0xFF, io[b] + RESET_OFFSET);
                        msleep_interruptible(10000);
                }
-               pr_debug("RAM Base for board %d is 0x%x, %s probe\n", b, ram[b],
-                       ram[b] == 0 ? "will" : "won't");
+               pr_debug("RAM Base for board %d is 0x%lx, %s probe\n", b,
+                       ram[b], ram[b] == 0 ? "will" : "won't");
 
                if(ram[b]) {
                        /*
@@ -168,7 +169,7 @@ static int __init sc_init(void)
                         * board model
                         */
                        if(request_region(ram[b], SRAM_PAGESIZE, "sc test")) {
-                               pr_debug("request_region for RAM base 0x%x succeeded\n", ram[b]);
+                               pr_debug("request_region for RAM base 0x%lx succeeded\n", ram[b]);
                                model = identify_board(ram[b], io[b]);
                                release_region(ram[b], SRAM_PAGESIZE);
                        }
@@ -204,7 +205,7 @@ static int __init sc_init(void)
                         * Nope, there was no place in RAM for the
                         * board, or it couldn't be identified
                         */
-                        pr_debug("Failed to find an adapter at 0x%x\n", ram[b]);
+                        pr_debug("Failed to find an adapter at 0x%lx\n", ram[b]);
                         continue;
                }
 
@@ -451,7 +452,7 @@ static int identify_board(unsigned long rambase, unsigned int iobase)
        HWConfig_pl hwci;
        int x;
 
-       pr_debug("Attempting to identify adapter @ 0x%x io 0x%x\n",
+       pr_debug("Attempting to identify adapter @ 0x%lx io 0x%x\n",
                rambase, iobase);
 
        /*
@@ -490,7 +491,7 @@ static int identify_board(unsigned long rambase, unsigned int iobase)
        outb(PRI_BASEPG_VAL, pgport);
        msleep_interruptible(1000);
        sig = readl(rambase + SIG_OFFSET);
-       pr_debug("Looking for a signature, got 0x%x\n", sig);
+       pr_debug("Looking for a signature, got 0x%lx\n", sig);
        if(sig == SIGNATURE)
                return PRI_BOARD;
 
@@ -500,7 +501,7 @@ static int identify_board(unsigned long rambase, unsigned int iobase)
        outb(BRI_BASEPG_VAL, pgport);
        msleep_interruptible(1000);
        sig = readl(rambase + SIG_OFFSET);
-       pr_debug("Looking for a signature, got 0x%x\n", sig);
+       pr_debug("Looking for a signature, got 0x%lx\n", sig);
        if(sig == SIGNATURE)
                return BRI_BOARD;
 
@@ -510,7 +511,7 @@ static int identify_board(unsigned long rambase, unsigned int iobase)
         * Try to spot a card
         */
        sig = readl(rambase + SIG_OFFSET);
-       pr_debug("Looking for a signature, got 0x%x\n", sig);
+       pr_debug("Looking for a signature, got 0x%lx\n", sig);
        if(sig != SIGNATURE)
                return -1;
 
@@ -540,7 +541,7 @@ static int identify_board(unsigned long rambase, unsigned int iobase)
        memcpy_fromio(&rcvmsg, &(dpm->rsp_queue[dpm->rsp_tail]), MSG_LEN);
        pr_debug("Got HWConfig response, status = 0x%x\n", rcvmsg.rsp_status);
        memcpy(&hwci, &(rcvmsg.msg_data.HWCresponse), sizeof(HWConfig_pl));
-       pr_debug("Hardware Config: Interface: %s, RAM Size: %d, Serial: %s\n"
+       pr_debug("Hardware Config: Interface: %s, RAM Size: %ld, Serial: %s\n"
                 "                 Part: %s, Rev: %s\n",
                 hwci.st_u_sense ? "S/T" : "U", hwci.ram_size,
                 hwci.serial_no, hwci.part_no, hwci.rev_no);
index f50defc..1e04676 100644 (file)
@@ -44,7 +44,7 @@ int sndpkt(int devId, int channel, struct sk_buff *data)
                return -ENODEV;
        }
 
-       pr_debug("%s: sndpkt: frst = 0x%x nxt = %d  f = %d n = %d\n",
+       pr_debug("%s: sndpkt: frst = 0x%lx nxt = %d  f = %d n = %d\n",
                sc_adapter[card]->devicename,
                sc_adapter[card]->channel[channel].first_sendbuf,
                sc_adapter[card]->channel[channel].next_sendbuf,
@@ -66,7 +66,7 @@ int sndpkt(int devId, int channel, struct sk_buff *data)
        ReqLnkWrite.buff_offset = sc_adapter[card]->channel[channel].next_sendbuf *
                BUFFER_SIZE + sc_adapter[card]->channel[channel].first_sendbuf;
        ReqLnkWrite.msg_len = data->len; /* sk_buff size */
-       pr_debug("%s: writing %d bytes to buffer offset 0x%x\n",
+       pr_debug("%s: writing %d bytes to buffer offset 0x%lx\n",
                        sc_adapter[card]->devicename,
                        ReqLnkWrite.msg_len, ReqLnkWrite.buff_offset);
        memcpy_toshmem(card, (char *)ReqLnkWrite.buff_offset, data->data, ReqLnkWrite.msg_len);
@@ -74,7 +74,7 @@ int sndpkt(int devId, int channel, struct sk_buff *data)
        /*
         * sendmessage
         */
-       pr_debug("%s: sndpkt size=%d, buf_offset=0x%x buf_indx=%d\n",
+       pr_debug("%s: sndpkt size=%d, buf_offset=0x%lx buf_indx=%d\n",
                sc_adapter[card]->devicename,
                ReqLnkWrite.msg_len, ReqLnkWrite.buff_offset,
                sc_adapter[card]->channel[channel].next_sendbuf);
@@ -124,7 +124,7 @@ void rcvpkt(int card, RspMessage *rcvmsg)
                        return;
                }
                skb_put(skb, rcvmsg->msg_data.response.msg_len);
-               pr_debug("%s: getting data from offset: 0x%x\n",
+               pr_debug("%s: getting data from offset: 0x%lx\n",
                        sc_adapter[card]->devicename,
                        rcvmsg->msg_data.response.buff_offset);
                memcpy_fromshmem(card,
@@ -143,7 +143,7 @@ void rcvpkt(int card, RspMessage *rcvmsg)
 /*             memset_shmem(card, rcvmsg->msg_data.response.buff_offset, 0, BUFFER_SIZE); */
                newll.buff_offset = rcvmsg->msg_data.response.buff_offset;
                newll.msg_len = BUFFER_SIZE;
-               pr_debug("%s: recycled buffer at offset 0x%x size %d\n",
+               pr_debug("%s: recycled buffer at offset 0x%lx size %d\n",
                        sc_adapter[card]->devicename,
                        newll.buff_offset, newll.msg_len);
                sendmessage(card, CEPID, ceReqTypeLnk, ceReqClass1, ceReqLnkRead,
@@ -186,7 +186,7 @@ int setup_buffers(int card, int c)
        sc_adapter[card]->channel[c-1].num_sendbufs = nBuffers / 2;
        sc_adapter[card]->channel[c-1].free_sendbufs = nBuffers / 2;
        sc_adapter[card]->channel[c-1].next_sendbuf = 0;
-       pr_debug("%s: send buffer setup complete: first=0x%x n=%d f=%d, nxt=%d\n",
+       pr_debug("%s: send buffer setup complete: first=0x%lx n=%d f=%d, nxt=%d\n",
                                sc_adapter[card]->devicename,
                                sc_adapter[card]->channel[c-1].first_sendbuf,
                                sc_adapter[card]->channel[c-1].num_sendbufs,
@@ -203,7 +203,7 @@ int setup_buffers(int card, int c)
                        ((sc_adapter[card]->channel[c-1].first_sendbuf +
                        (nBuffers / 2) * buffer_size) + (buffer_size * i));
                RcvBuffOffset.msg_len = buffer_size;
-               pr_debug("%s: adding RcvBuffer #%d offset=0x%x sz=%d bufsz:%d\n",
+               pr_debug("%s: adding RcvBuffer #%d offset=0x%lx sz=%d bufsz:%d\n",
                                sc_adapter[card]->devicename,
                                i + 1, RcvBuffOffset.buff_offset, 
                                RcvBuffOffset.msg_len,buffer_size);
index 2485482..6f58862 100644 (file)
@@ -61,7 +61,7 @@ void memcpy_toshmem(int card, void *dest, const void *src, size_t n)
        spin_unlock_irqrestore(&sc_adapter[card]->lock, flags);
        pr_debug("%s: set page to %#x\n",sc_adapter[card]->devicename,
                ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80);
-       pr_debug("%s: copying %d bytes from %#x to %#x\n",
+       pr_debug("%s: copying %d bytes from %#lx to %#lx\n",
                sc_adapter[card]->devicename, n,
                (unsigned long) src,
                sc_adapter[card]->rambase + ((unsigned long) dest %0x4000));
index 09baa43..da862e4 100644 (file)
@@ -100,6 +100,7 @@ static DEVICE_ATTR(pos, S_IRUGO, mca_show_pos, NULL);
 int __init mca_register_device(int bus, struct mca_device *mca_dev)
 {
        struct mca_bus *mca_bus = mca_root_busses[bus];
+       int rc;
 
        mca_dev->dev.parent = &mca_bus->dev;
        mca_dev->dev.bus = &mca_bus_type;
@@ -108,13 +109,23 @@ int __init mca_register_device(int bus, struct mca_device *mca_dev)
        mca_dev->dev.dma_mask = &mca_dev->dma_mask;
        mca_dev->dev.coherent_dma_mask = mca_dev->dma_mask;
 
-       if (device_register(&mca_dev->dev))
-               return 0;
+       rc = device_register(&mca_dev->dev);
+       if (rc)
+               goto err_out;
 
-       device_create_file(&mca_dev->dev, &dev_attr_id);
-       device_create_file(&mca_dev->dev, &dev_attr_pos);
+       rc = device_create_file(&mca_dev->dev, &dev_attr_id);
+       if (rc) goto err_out_devreg;
+       rc = device_create_file(&mca_dev->dev, &dev_attr_pos);
+       if (rc) goto err_out_id;
 
        return 1;
+
+err_out_id:
+       device_remove_file(&mca_dev->dev, &dev_attr_id);
+err_out_devreg:
+       device_unregister(&mca_dev->dev);
+err_out:
+       return 0;
 }
 
 /* */
@@ -130,13 +141,16 @@ struct mca_bus * __devinit mca_attach_bus(int bus)
                return NULL;
        }
 
-       mca_bus = kmalloc(sizeof(struct mca_bus), GFP_KERNEL);
+       mca_bus = kzalloc(sizeof(struct mca_bus), GFP_KERNEL);
        if (!mca_bus)
                return NULL;
-       memset(mca_bus, 0, sizeof(struct mca_bus));
+
        sprintf(mca_bus->dev.bus_id,"mca%d",bus);
        sprintf(mca_bus->name,"Host %s MCA Bridge", bus ? "Secondary" : "Primary");
-       device_register(&mca_bus->dev);
+       if (device_register(&mca_bus->dev)) {
+               kfree(mca_bus);
+               return NULL;
+       }
 
        mca_root_busses[bus] = mca_bus;
 
index 8e67634..d47d38a 100644 (file)
@@ -1413,7 +1413,7 @@ int bitmap_create(mddev_t *mddev)
        int err;
        sector_t start;
 
-       BUG_ON(sizeof(bitmap_super_t) != 256);
+       BUILD_BUG_ON(sizeof(bitmap_super_t) != 256);
 
        if (!file && !mddev->bitmap_offset) /* bitmap disabled, nothing to do */
                return 0;
index 8cc3c33..b7b8bc2 100644 (file)
@@ -162,9 +162,9 @@ static char *version =
 #include <linux/skbuff.h>
 #include <linux/bitops.h>
 #include <linux/jiffies.h>
+#include <linux/io.h>
 
 #include <asm/system.h>
-#include <asm/io.h>
 #include <asm/dma.h>
 
 
index d1d1885..a3220a9 100644 (file)
@@ -330,7 +330,7 @@ out2:
 out1:
        free_netdev(dev);
 out:
-       iounmap((void *)ioaddr);
+       iounmap((void __iomem *)ioaddr);
        return ERR_PTR(err);
 }
 
index 91c7654..b865db3 100644 (file)
@@ -286,7 +286,7 @@ struct net_device * __init sun3lance_probe(int unit)
 
 out1:
 #ifdef CONFIG_SUN3
-       iounmap((void *)dev->base_addr);
+       iounmap((void __iomem *)dev->base_addr);
 #endif
 out:
        free_netdev(dev);
@@ -326,7 +326,7 @@ static int __init lance_probe( struct net_device *dev)
                ioaddr_probe[1] = tmp2;
 
 #ifdef CONFIG_SUN3
-               iounmap((void *)ioaddr);
+               iounmap((void __iomem *)ioaddr);
 #endif
                return 0;
        }
@@ -956,7 +956,7 @@ void cleanup_module(void)
 {
        unregister_netdev(sun3lance_dev);
 #ifdef CONFIG_SUN3
-       iounmap((void *)sun3lance_dev->base_addr);
+       iounmap((void __iomem *)sun3lance_dev->base_addr);
 #endif
        free_netdev(sun3lance_dev);
 }
index 3029412..ecc50db 100644 (file)
@@ -55,7 +55,7 @@ config PCI_DEBUG
 config HT_IRQ
        bool "Interrupts on hypertransport devices"
        default y
-       depends on X86_LOCAL_APIC && X86_IO_APIC
+       depends on PCI && X86_LOCAL_APIC && X86_IO_APIC
        help
           This allows native hypertransport devices to use interrupts.
 
index a0d1cee..306f46b 100644 (file)
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <asm/irq.h>
-#include <asm/io.h>
+#include <linux/io.h>
 #include <linux/blkdev.h>
 #include <asm/system.h>
 #include <linux/errno.h>
index 0d5713d..5475672 100644 (file)
@@ -82,7 +82,7 @@
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
-#include <asm/io.h>
+#include <linux/io.h>
 #include "scsi.h"
 #include <scsi/scsi_host.h>
 #include "dtc.h"
index 41b05fc..72794a7 100644 (file)
 #include <linux/pci.h>
 #include <linux/stat.h>
 #include <linux/delay.h>
+#include <linux/io.h>
 #include <scsi/scsicam.h>
 
-#include <asm/io.h>
 #include <asm/system.h>
 
 #include <scsi/scsi.h>
index 8ff1f28..5ffec27 100644 (file)
@@ -97,8 +97,8 @@
 #include <linux/blkdev.h>
 #include <linux/stat.h>
 #include <linux/delay.h>
+#include <linux/io.h>
 
-#include <asm/io.h>
 #include <asm/system.h>
 #include <asm/uaccess.h>
 
index 2df6747..0b7a70f 100644 (file)
 #include <asm/system.h>
 #include <linux/signal.h>
 #include <linux/sched.h>
-#include <asm/io.h>
+#include <linux/io.h>
 #include <linux/blkdev.h>
 #include <linux/interrupt.h>
 #include <linux/stat.h>
index 331e1cf..30be765 100644 (file)
 #include <linux/blkdev.h>
 #include <linux/init.h>
 #include <linux/stat.h>
+#include <linux/io.h>
 
 #include <asm/system.h>
 #include <asm/dma.h>
-#include <asm/io.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
index daaa486..7a43020 100644 (file)
@@ -701,7 +701,6 @@ config FB_NVIDIA
        depends on FB && PCI
        select I2C_ALGOBIT if FB_NVIDIA_I2C
        select I2C if FB_NVIDIA_I2C
-       select FB_DDC if FB_NVIDIA_I2C
        select FB_MODE_HELPERS
        select FB_CFB_FILLRECT
        select FB_CFB_COPYAREA
index e48de3c..19eef3a 100644 (file)
@@ -160,12 +160,51 @@ void nvidia_delete_i2c_busses(struct nvidia_par *par)
 
 }
 
+static u8 *nvidia_do_probe_i2c_edid(struct nvidia_i2c_chan *chan)
+{
+       u8 start = 0x0;
+       struct i2c_msg msgs[] = {
+               {
+                .addr = 0x50,
+                .len = 1,
+                .buf = &start,
+                }, {
+                    .addr = 0x50,
+                    .flags = I2C_M_RD,
+                    .len = EDID_LENGTH,
+                    },
+       };
+       u8 *buf;
+
+       if (!chan->par)
+               return NULL;
+
+       buf = kmalloc(EDID_LENGTH, GFP_KERNEL);
+       if (!buf) {
+               dev_warn(&chan->par->pci_dev->dev, "Out of memory!\n");
+               return NULL;
+       }
+       msgs[1].buf = buf;
+
+       if (i2c_transfer(&chan->adapter, msgs, 2) == 2)
+               return buf;
+       dev_dbg(&chan->par->pci_dev->dev, "Unable to read EDID block.\n");
+       kfree(buf);
+       return NULL;
+}
+
 int nvidia_probe_i2c_connector(struct fb_info *info, int conn, u8 **out_edid)
 {
        struct nvidia_par *par = info->par;
-       u8 *edid;
-
-       edid = fb_ddc_read(&par->chan[conn - 1].adapter);
+       u8 *edid = NULL;
+       int i;
+
+       for (i = 0; i < 3; i++) {
+               /* Do the real work */
+               edid = nvidia_do_probe_i2c_edid(&par->chan[conn - 1]);
+               if (edid)
+                       break;
+       }
 
        if (!edid && conn == 1) {
                /* try to get from firmware */
index 599de54..db4d133 100644 (file)
@@ -140,6 +140,73 @@ config EXT3_FS_SECURITY
          If you are not using a security module that requires using
          extended attributes for file security labels, say N.
 
+config EXT4DEV_FS
+       tristate "Ext4dev/ext4 extended fs support development (EXPERIMENTAL)"
+       depends on EXPERIMENTAL
+       select JBD2
+       help
+         Ext4dev is a predecessor filesystem of the next generation
+         extended fs ext4, based on ext3 filesystem code. It will be
+         renamed ext4 fs later, once ext4dev is mature and stabilized.
+
+         Unlike the change from ext2 filesystem to ext3 filesystem,
+         the on-disk format of ext4dev is not the same as ext3 any more:
+         it is based on extent maps and it supports 48-bit physical block
+         numbers. These combined on-disk format changes will allow
+         ext4dev/ext4 to handle more than 16 TB filesystem volumes --
+         a hard limit that ext3 cannot overcome without changing the
+         on-disk format.
+
+         Other than extent maps and 48-bit block numbers, ext4dev also is
+         likely to have other new features such as persistent preallocation,
+         high resolution time stamps, and larger file support etc.  These
+         features will be added to ext4dev gradually.
+
+         To compile this file system support as a module, choose M here. The
+         module will be called ext4dev.  Be aware, however, that the filesystem
+         of your root partition (the one containing the directory /) cannot
+         be compiled as a module, and so this could be dangerous.
+
+         If unsure, say N.
+
+config EXT4DEV_FS_XATTR
+       bool "Ext4dev extended attributes"
+       depends on EXT4DEV_FS
+       default y
+       help
+         Extended attributes are name:value pairs associated with inodes by
+         the kernel or by users (see the attr(5) manual page, or visit
+         <http://acl.bestbits.at/> for details).
+
+         If unsure, say N.
+
+         You need this for POSIX ACL support on ext4dev/ext4.
+
+config EXT4DEV_FS_POSIX_ACL
+       bool "Ext4dev POSIX Access Control Lists"
+       depends on EXT4DEV_FS_XATTR
+       select FS_POSIX_ACL
+       help
+         POSIX Access Control Lists (ACLs) support permissions for users and
+         groups beyond the owner/group/world scheme.
+
+         To learn more about Access Control Lists, visit the POSIX ACLs for
+         Linux website <http://acl.bestbits.at/>.
+
+         If you don't know what Access Control Lists are, say N
+
+config EXT4DEV_FS_SECURITY
+       bool "Ext4dev Security Labels"
+       depends on EXT4DEV_FS_XATTR
+       help
+         Security labels support alternative access control models
+         implemented by security modules like SELinux.  This option
+         enables an extended attribute handler for file security
+         labels in the ext4dev/ext4 filesystem.
+
+         If you are not using a security module that requires using
+         extended attributes for file security labels, say N.
+
 config JBD
        tristate
        help
@@ -172,12 +239,44 @@ config JBD_DEBUG
          generated.  To turn debugging off again, do
          "echo 0 > /proc/sys/fs/jbd-debug".
 
+config JBD2
+       tristate
+       help
+         This is a generic journaling layer for block devices that support
+         both 32-bit and 64-bit block numbers.  It is currently used by
+         the ext4dev/ext4 filesystem, but it could also be used to add
+         journal support to other file systems or block devices such
+         as RAID or LVM.
+
+         If you are using ext4dev/ext4, you need to say Y here. If you are not
+         using ext4dev/ext4 then you will probably want to say N.
+
+         To compile this device as a module, choose M here. The module will be
+         called jbd2.  If you are compiling ext4dev/ext4 into the kernel,
+         you cannot compile this code as a module.
+
+config JBD2_DEBUG
+       bool "JBD2 (ext4dev/ext4) debugging support"
+       depends on JBD2
+       help
+         If you are using the ext4dev/ext4 journaled file system (or
+         potentially any other filesystem/device using JBD2), this option
+         allows you to enable debugging output while the system is running,
+         in order to help track down any problems you are having.
+         By default, the debugging output will be turned off.
+
+         If you select Y here, then you will be able to turn on debugging
+         with "echo N > /proc/sys/fs/jbd2-debug", where N is a number between
+         1 and 5. The higher the number, the more debugging output is
+         generated.  To turn debugging off again, do
+         "echo 0 > /proc/sys/fs/jbd2-debug".
+
 config FS_MBCACHE
-# Meta block cache for Extended Attributes (ext2/ext3)
+# Meta block cache for Extended Attributes (ext2/ext3/ext4)
        tristate
-       depends on EXT2_FS_XATTR || EXT3_FS_XATTR
-       default y if EXT2_FS=y || EXT3_FS=y
-       default m if EXT2_FS=m || EXT3_FS=m
+       depends on EXT2_FS_XATTR || EXT3_FS_XATTR || EXT4DEV_FS_XATTR
+       default y if EXT2_FS=y || EXT3_FS=y || EXT4DEV_FS=y
+       default m if EXT2_FS=m || EXT3_FS=m || EXT4DEV_FS=m
 
 config REISERFS_FS
        tristate "Reiserfs support"
index df614ea..9a5ce93 100644 (file)
@@ -62,7 +62,9 @@ obj-$(CONFIG_DLM)             += dlm/
 # Do not add any filesystems before this line
 obj-$(CONFIG_REISERFS_FS)      += reiserfs/
 obj-$(CONFIG_EXT3_FS)          += ext3/ # Before ext2 so root fs can be ext3
+obj-$(CONFIG_EXT4DEV_FS)       += ext4/ # Before ext2 so root fs can be ext4dev
 obj-$(CONFIG_JBD)              += jbd/
+obj-$(CONFIG_JBD2)             += jbd2/
 obj-$(CONFIG_EXT2_FS)          += ext2/
 obj-$(CONFIG_CRAMFS)           += cramfs/
 obj-$(CONFIG_RAMFS)            += ramfs/
index cf8a2cb..a6ec75c 100644 (file)
@@ -211,8 +211,8 @@ static int afs_dir_open(struct inode *inode, struct file *file)
 {
        _enter("{%lu}", inode->i_ino);
 
-       BUG_ON(sizeof(union afs_dir_block) != 2048);
-       BUG_ON(sizeof(union afs_dirent) != 32);
+       BUILD_BUG_ON(sizeof(union afs_dir_block) != 2048);
+       BUILD_BUG_ON(sizeof(union afs_dirent) != 32);
 
        if (AFS_FS_I(inode)->flags & AFS_VNODE_DELETED)
                return -ENOENT;
@@ -446,8 +446,8 @@ static struct dentry *afs_dir_lookup(struct inode *dir, struct dentry *dentry,
        _enter("{%lu},%p{%s}", dir->i_ino, dentry, dentry->d_name.name);
 
        /* insanity checks first */
-       BUG_ON(sizeof(union afs_dir_block) != 2048);
-       BUG_ON(sizeof(union afs_dirent) != 32);
+       BUILD_BUG_ON(sizeof(union afs_dir_block) != 2048);
+       BUILD_BUG_ON(sizeof(union afs_dirent) != 32);
 
        if (dentry->d_name.len > 255) {
                _leave(" = -ENAMETOOLONG");
index 480ab17..b13f32c 100644 (file)
@@ -94,7 +94,6 @@ struct autofs_wait_queue {
 
 struct autofs_sb_info {
        u32 magic;
-       struct dentry *root;
        int pipefd;
        struct file *pipe;
        pid_t oz_pgrp;
@@ -229,4 +228,4 @@ out:
 }
 
 void autofs4_dentry_release(struct dentry *);
-
+extern void autofs4_kill_sb(struct super_block *);
index 5d91933..723a1c5 100644 (file)
@@ -24,7 +24,7 @@ static struct file_system_type autofs_fs_type = {
        .owner          = THIS_MODULE,
        .name           = "autofs",
        .get_sb         = autofs_get_sb,
-       .kill_sb        = kill_anon_super,
+       .kill_sb        = autofs4_kill_sb,
 };
 
 static int __init init_autofs4_fs(void)
index 800ce87..51fd859 100644 (file)
@@ -96,7 +96,7 @@ void autofs4_free_ino(struct autofs_info *ino)
  */
 static void autofs4_force_release(struct autofs_sb_info *sbi)
 {
-       struct dentry *this_parent = sbi->root;
+       struct dentry *this_parent = sbi->sb->s_root;
        struct list_head *next;
 
        spin_lock(&dcache_lock);
@@ -127,7 +127,7 @@ resume:
                spin_lock(&dcache_lock);
        }
 
-       if (this_parent != sbi->root) {
+       if (this_parent != sbi->sb->s_root) {
                struct dentry *dentry = this_parent;
 
                next = this_parent->d_u.d_child.next;
@@ -140,15 +140,9 @@ resume:
                goto resume;
        }
        spin_unlock(&dcache_lock);
-
-       dput(sbi->root);
-       sbi->root = NULL;
-       shrink_dcache_sb(sbi->sb);
-
-       return;
 }
 
-static void autofs4_put_super(struct super_block *sb)
+void autofs4_kill_sb(struct super_block *sb)
 {
        struct autofs_sb_info *sbi = autofs4_sbi(sb);
 
@@ -163,6 +157,7 @@ static void autofs4_put_super(struct super_block *sb)
        kfree(sbi);
 
        DPRINTK("shutting down");
+       kill_anon_super(sb);
 }
 
 static int autofs4_show_options(struct seq_file *m, struct vfsmount *mnt)
@@ -189,7 +184,6 @@ static int autofs4_show_options(struct seq_file *m, struct vfsmount *mnt)
 }
 
 static struct super_operations autofs4_sops = {
-       .put_super      = autofs4_put_super,
        .statfs         = simple_statfs,
        .show_options   = autofs4_show_options,
 };
@@ -315,7 +309,6 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
 
        s->s_fs_info = sbi;
        sbi->magic = AUTOFS_SBI_MAGIC;
-       sbi->root = NULL;
        sbi->pipefd = -1;
        sbi->catatonic = 0;
        sbi->exp_timeout = 0;
@@ -396,13 +389,6 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
        sbi->pipe = pipe;
        sbi->pipefd = pipefd;
 
-       /*
-        * Take a reference to the root dentry so we get a chance to
-        * clean up the dentry tree on umount.
-        * See autofs4_force_release.
-        */
-       sbi->root = dget(root);
-
        /*
         * Success! Install the root dentry now to indicate completion.
         */
index ce103e7..c0a6c8d 100644 (file)
@@ -45,7 +45,6 @@ void autofs4_catatonic_mode(struct autofs_sb_info *sbi)
                fput(sbi->pipe);        /* Close the pipe */
                sbi->pipe = NULL;
        }
-       shrink_dcache_sb(sbi->sb);
 }
 
 static int autofs4_write(struct file *file, const void *addr, int bytes)
index 8f93e93..f95c874 100644 (file)
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -79,7 +79,6 @@ static struct bio_set *fs_bio_set;
 static inline struct bio_vec *bvec_alloc_bs(gfp_t gfp_mask, int nr, unsigned long *idx, struct bio_set *bs)
 {
        struct bio_vec *bvl;
-       struct biovec_slab *bp;
 
        /*
         * see comment near bvec_array define!
@@ -98,10 +97,12 @@ static inline struct bio_vec *bvec_alloc_bs(gfp_t gfp_mask, int nr, unsigned lon
         * idx now points to the pool we want to allocate from
         */
 
-       bp = bvec_slabs + *idx;
        bvl = mempool_alloc(bs->bvec_pools[*idx], gfp_mask);
-       if (bvl)
+       if (bvl) {
+               struct biovec_slab *bp = bvec_slabs + *idx;
+
                memset(bvl, 0, bp->nr_vecs * sizeof(struct bio_vec));
+       }
 
        return bvl;
 }
@@ -166,7 +167,7 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs)
 
                bio_init(bio);
                if (likely(nr_iovecs)) {
-                       unsigned long idx;
+                       unsigned long idx = 0; /* shut up gcc */
 
                        bvl = bvec_alloc_bs(gfp_mask, nr_iovecs, &idx, bs);
                        if (unlikely(!bvl)) {
index eeb8ac1..f65ef88 100644 (file)
@@ -1042,8 +1042,21 @@ grow_buffers(struct block_device *bdev, sector_t block, int size)
        } while ((size << sizebits) < PAGE_SIZE);
 
        index = block >> sizebits;
-       block = index << sizebits;
 
+       /*
+        * Check for a block which wants to lie outside our maximum possible
+        * pagecache index.  (this comparison is done using sector_t types).
+        */
+       if (unlikely(index != block >> sizebits)) {
+               char b[BDEVNAME_SIZE];
+
+               printk(KERN_ERR "%s: requested out-of-range block %llu for "
+                       "device %s\n",
+                       __FUNCTION__, (unsigned long long)block,
+                       bdevname(bdev, b));
+               return -EIO;
+       }
+       block = index << sizebits;
        /* Create a page with the proper size buffers.. */
        page = grow_dev_page(bdev, block, index, size);
        if (!page)
@@ -1070,12 +1083,16 @@ __getblk_slow(struct block_device *bdev, sector_t block, int size)
 
        for (;;) {
                struct buffer_head * bh;
+               int ret;
 
                bh = __find_get_block(bdev, block, size);
                if (bh)
                        return bh;
 
-               if (!grow_buffers(bdev, block, size))
+               ret = grow_buffers(bdev, block, size);
+               if (ret < 0)
+                       return NULL;
+               if (ret == 0)
                        free_more_memory();
        }
 }
@@ -1837,6 +1854,7 @@ static int __block_prepare_write(struct inode *inode, struct page *page,
                        clear_buffer_new(bh);
                        kaddr = kmap_atomic(page, KM_USER0);
                        memset(kaddr+block_start, 0, bh->b_size);
+                       flush_dcache_page(page);
                        kunmap_atomic(kaddr, KM_USER0);
                        set_buffer_uptodate(bh);
                        mark_buffer_dirty(bh);
@@ -2343,6 +2361,7 @@ failed:
         */
        kaddr = kmap_atomic(page, KM_USER0);
        memset(kaddr, 0, PAGE_CACHE_SIZE);
+       flush_dcache_page(page);
        kunmap_atomic(kaddr, KM_USER0);
        SetPageUptodate(page);
        set_page_dirty(page);
index 27ca1aa..a91f262 100644 (file)
@@ -2438,13 +2438,17 @@ HANDLE_IOCTL(0x1260, broken_blkgetsize)
 HANDLE_IOCTL(BLKFRAGET, w_long)
 HANDLE_IOCTL(BLKSECTGET, w_long)
 HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans)
-HANDLE_IOCTL(HDIO_GET_KEEPSETTINGS, hdio_ioctl_trans)
 HANDLE_IOCTL(HDIO_GET_UNMASKINTR, hdio_ioctl_trans)
-HANDLE_IOCTL(HDIO_GET_DMA, hdio_ioctl_trans)
-HANDLE_IOCTL(HDIO_GET_32BIT, hdio_ioctl_trans)
 HANDLE_IOCTL(HDIO_GET_MULTCOUNT, hdio_ioctl_trans)
+HANDLE_IOCTL(HDIO_GET_KEEPSETTINGS, hdio_ioctl_trans)
+HANDLE_IOCTL(HDIO_GET_32BIT, hdio_ioctl_trans)
 HANDLE_IOCTL(HDIO_GET_NOWERR, hdio_ioctl_trans)
+HANDLE_IOCTL(HDIO_GET_DMA, hdio_ioctl_trans)
 HANDLE_IOCTL(HDIO_GET_NICE, hdio_ioctl_trans)
+HANDLE_IOCTL(HDIO_GET_WCACHE, hdio_ioctl_trans)
+HANDLE_IOCTL(HDIO_GET_ACOUSTIC, hdio_ioctl_trans)
+HANDLE_IOCTL(HDIO_GET_ADDRESS, hdio_ioctl_trans)
+HANDLE_IOCTL(HDIO_GET_BUSSTATE, hdio_ioctl_trans)
 HANDLE_IOCTL(FDSETPRM32, fd_ioctl_trans)
 HANDLE_IOCTL(FDDEFPRM32, fd_ioctl_trans)
 HANDLE_IOCTL(FDGETPRM32, fd_ioctl_trans)
index 2355bdd..2bac4ba 100644 (file)
@@ -548,6 +548,136 @@ repeat:
        spin_unlock(&dcache_lock);
 }
 
+/*
+ * destroy a single subtree of dentries for unmount
+ * - see the comments on shrink_dcache_for_umount() for a description of the
+ *   locking
+ */
+static void shrink_dcache_for_umount_subtree(struct dentry *dentry)
+{
+       struct dentry *parent;
+
+       BUG_ON(!IS_ROOT(dentry));
+
+       /* detach this root from the system */
+       spin_lock(&dcache_lock);
+       if (!list_empty(&dentry->d_lru)) {
+               dentry_stat.nr_unused--;
+               list_del_init(&dentry->d_lru);
+       }
+       __d_drop(dentry);
+       spin_unlock(&dcache_lock);
+
+       for (;;) {
+               /* descend to the first leaf in the current subtree */
+               while (!list_empty(&dentry->d_subdirs)) {
+                       struct dentry *loop;
+
+                       /* this is a branch with children - detach all of them
+                        * from the system in one go */
+                       spin_lock(&dcache_lock);
+                       list_for_each_entry(loop, &dentry->d_subdirs,
+                                           d_u.d_child) {
+                               if (!list_empty(&loop->d_lru)) {
+                                       dentry_stat.nr_unused--;
+                                       list_del_init(&loop->d_lru);
+                               }
+
+                               __d_drop(loop);
+                               cond_resched_lock(&dcache_lock);
+                       }
+                       spin_unlock(&dcache_lock);
+
+                       /* move to the first child */
+                       dentry = list_entry(dentry->d_subdirs.next,
+                                           struct dentry, d_u.d_child);
+               }
+
+               /* consume the dentries from this leaf up through its parents
+                * until we find one with children or run out altogether */
+               do {
+                       struct inode *inode;
+
+                       if (atomic_read(&dentry->d_count) != 0) {
+                               printk(KERN_ERR
+                                      "BUG: Dentry %p{i=%lx,n=%s}"
+                                      " still in use (%d)"
+                                      " [unmount of %s %s]\n",
+                                      dentry,
+                                      dentry->d_inode ?
+                                      dentry->d_inode->i_ino : 0UL,
+                                      dentry->d_name.name,
+                                      atomic_read(&dentry->d_count),
+                                      dentry->d_sb->s_type->name,
+                                      dentry->d_sb->s_id);
+                               BUG();
+                       }
+
+                       parent = dentry->d_parent;
+                       if (parent == dentry)
+                               parent = NULL;
+                       else
+                               atomic_dec(&parent->d_count);
+
+                       list_del(&dentry->d_u.d_child);
+                       dentry_stat.nr_dentry--;        /* For d_free, below */
+
+                       inode = dentry->d_inode;
+                       if (inode) {
+                               dentry->d_inode = NULL;
+                               list_del_init(&dentry->d_alias);
+                               if (dentry->d_op && dentry->d_op->d_iput)
+                                       dentry->d_op->d_iput(dentry, inode);
+                               else
+                                       iput(inode);
+                       }
+
+                       d_free(dentry);
+
+                       /* finished when we fall off the top of the tree,
+                        * otherwise we ascend to the parent and move to the
+                        * next sibling if there is one */
+                       if (!parent)
+                               return;
+
+                       dentry = parent;
+
+               } while (list_empty(&dentry->d_subdirs));
+
+               dentry = list_entry(dentry->d_subdirs.next,
+                                   struct dentry, d_u.d_child);
+       }
+}
+
+/*
+ * destroy the dentries attached to a superblock on unmounting
+ * - we don't need to use dentry->d_lock, and only need dcache_lock when
+ *   removing the dentry from the system lists and hashes because:
+ *   - the superblock is detached from all mountings and open files, so the
+ *     dentry trees will not be rearranged by the VFS
+ *   - s_umount is write-locked, so the memory pressure shrinker will ignore
+ *     any dentries belonging to this superblock that it comes across
+ *   - the filesystem itself is no longer permitted to rearrange the dentries
+ *     in this superblock
+ */
+void shrink_dcache_for_umount(struct super_block *sb)
+{
+       struct dentry *dentry;
+
+       if (down_read_trylock(&sb->s_umount))
+               BUG();
+
+       dentry = sb->s_root;
+       sb->s_root = NULL;
+       atomic_dec(&dentry->d_count);
+       shrink_dcache_for_umount_subtree(dentry);
+
+       while (!hlist_empty(&sb->s_anon)) {
+               dentry = hlist_entry(sb->s_anon.first, struct dentry, d_hash);
+               shrink_dcache_for_umount_subtree(dentry);
+       }
+}
+
 /*
  * Search for at least 1 mount point in the dentry's subdirs.
  * We descend to the next level whenever the d_subdirs
index 557d5b6..ae228ec 100644 (file)
 /* Maximum msec timeout value storeable in a long int */
 #define EP_MAX_MSTIMEO min(1000ULL * MAX_SCHEDULE_TIMEOUT / HZ, (LONG_MAX - 999ULL) / HZ)
 
+#define EP_MAX_EVENTS (INT_MAX / sizeof(struct epoll_event))
+
 
 struct epoll_filefd {
        struct file *file;
@@ -497,7 +499,7 @@ void eventpoll_release_file(struct file *file)
  */
 asmlinkage long sys_epoll_create(int size)
 {
-       int error, fd;
+       int error, fd = -1;
        struct eventpoll *ep;
        struct inode *inode;
        struct file *file;
@@ -640,7 +642,6 @@ eexit_1:
        return error;
 }
 
-#define MAX_EVENTS (INT_MAX / sizeof(struct epoll_event))
 
 /*
  * Implement the event wait interface for the eventpoll file. It is the kernel
@@ -657,7 +658,7 @@ asmlinkage long sys_epoll_wait(int epfd, struct epoll_event __user *events,
                     current, epfd, events, maxevents, timeout));
 
        /* The maximum number of event must be greater than zero */
-       if (maxevents <= 0 || maxevents > MAX_EVENTS)
+       if (maxevents <= 0 || maxevents > EP_MAX_EVENTS)
                return -EINVAL;
 
        /* Verify that the area passed by the user is writeable */
@@ -699,6 +700,55 @@ eexit_1:
 }
 
 
+#ifdef TIF_RESTORE_SIGMASK
+
+/*
+ * Implement the event wait interface for the eventpoll file. It is the kernel
+ * part of the user space epoll_pwait(2).
+ */
+asmlinkage long sys_epoll_pwait(int epfd, struct epoll_event __user *events,
+               int maxevents, int timeout, const sigset_t __user *sigmask,
+               size_t sigsetsize)
+{
+       int error;
+       sigset_t ksigmask, sigsaved;
+
+       /*
+        * If the caller wants a certain signal mask to be set during the wait,
+        * we apply it here.
+        */
+       if (sigmask) {
+               if (sigsetsize != sizeof(sigset_t))
+                       return -EINVAL;
+               if (copy_from_user(&ksigmask, sigmask, sizeof(ksigmask)))
+                       return -EFAULT;
+               sigdelsetmask(&ksigmask, sigmask(SIGKILL) | sigmask(SIGSTOP));
+               sigprocmask(SIG_SETMASK, &ksigmask, &sigsaved);
+       }
+
+       error = sys_epoll_wait(epfd, events, maxevents, timeout);
+
+       /*
+        * If we changed the signal mask, we need to restore the original one.
+        * In case we've got a signal while waiting, we do not restore the
+        * signal mask yet, and we allow do_signal() to deliver the signal on
+        * the way back to userspace, before the signal mask is restored.
+        */
+       if (sigmask) {
+               if (error == -EINTR) {
+                       memcpy(&current->saved_sigmask, &sigsaved,
+                               sizeof(sigsaved));
+                       set_thread_flag(TIF_RESTORE_SIGMASK);
+               } else
+                       sigprocmask(SIG_SETMASK, &sigsaved, NULL);
+       }
+
+       return error;
+}
+
+#endif /* #ifdef TIF_RESTORE_SIGMASK */
+
+
 /*
  * Creates the file descriptor to be used by the epoll interface.
  */
index 513cd42..d8b9abd 100644 (file)
@@ -364,7 +364,6 @@ static int parse_options (char * options,
 {
        char * p;
        substring_t args[MAX_OPT_ARGS];
-       unsigned long kind = EXT2_MOUNT_ERRORS_CONT;
        int option;
 
        if (!options)
@@ -404,13 +403,19 @@ static int parse_options (char * options,
                        /* *sb_block = match_int(&args[0]); */
                        break;
                case Opt_err_panic:
-                       kind = EXT2_MOUNT_ERRORS_PANIC;
+                       clear_opt (sbi->s_mount_opt, ERRORS_CONT);
+                       clear_opt (sbi->s_mount_opt, ERRORS_RO);
+                       set_opt (sbi->s_mount_opt, ERRORS_PANIC);
                        break;
                case Opt_err_ro:
-                       kind = EXT2_MOUNT_ERRORS_RO;
+                       clear_opt (sbi->s_mount_opt, ERRORS_CONT);
+                       clear_opt (sbi->s_mount_opt, ERRORS_PANIC);
+                       set_opt (sbi->s_mount_opt, ERRORS_RO);
                        break;
                case Opt_err_cont:
-                       kind = EXT2_MOUNT_ERRORS_CONT;
+                       clear_opt (sbi->s_mount_opt, ERRORS_RO);
+                       clear_opt (sbi->s_mount_opt, ERRORS_PANIC);
+                       set_opt (sbi->s_mount_opt, ERRORS_CONT);
                        break;
                case Opt_nouid32:
                        set_opt (sbi->s_mount_opt, NO_UID32);
@@ -489,7 +494,6 @@ static int parse_options (char * options,
                        return 0;
                }
        }
-       sbi->s_mount_opt |= kind;
        return 1;
 }
 
@@ -715,6 +719,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
                set_opt(sbi->s_mount_opt, ERRORS_PANIC);
        else if (le16_to_cpu(sbi->s_es->s_errors) == EXT2_ERRORS_RO)
                set_opt(sbi->s_mount_opt, ERRORS_RO);
+       else
+               set_opt(sbi->s_mount_opt, ERRORS_CONT);
 
        sbi->s_resuid = le16_to_cpu(es->s_def_resuid);
        sbi->s_resgid = le16_to_cpu(es->s_def_resgid);
index 8bfd56e..afc2d4f 100644 (file)
@@ -1470,6 +1470,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
                set_opt(sbi->s_mount_opt, ERRORS_PANIC);
        else if (le16_to_cpu(sbi->s_es->s_errors) == EXT3_ERRORS_RO)
                set_opt(sbi->s_mount_opt, ERRORS_RO);
+       else
+               set_opt(sbi->s_mount_opt, ERRORS_CONT);
 
        sbi->s_resuid = le16_to_cpu(es->s_def_resuid);
        sbi->s_resgid = le16_to_cpu(es->s_def_resgid);
diff --git a/fs/ext4/Makefile b/fs/ext4/Makefile
new file mode 100644 (file)
index 0000000..a6acb96
--- /dev/null
@@ -0,0 +1,12 @@
+#
+# Makefile for the linux ext4-filesystem routines.
+#
+
+obj-$(CONFIG_EXT4DEV_FS) += ext4dev.o
+
+ext4dev-y      := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
+          ioctl.o namei.o super.o symlink.o hash.o resize.o extents.o
+
+ext4dev-$(CONFIG_EXT4DEV_FS_XATTR)     += xattr.o xattr_user.o xattr_trusted.o
+ext4dev-$(CONFIG_EXT4DEV_FS_POSIX_ACL) += acl.o
+ext4dev-$(CONFIG_EXT4DEV_FS_SECURITY)  += xattr_security.o
diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
new file mode 100644 (file)
index 0000000..9e88254
--- /dev/null
@@ -0,0 +1,551 @@
+/*
+ * linux/fs/ext4/acl.c
+ *
+ * Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de>
+ */
+
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/capability.h>
+#include <linux/fs.h>
+#include <linux/ext4_jbd2.h>
+#include <linux/ext4_fs.h>
+#include "xattr.h"
+#include "acl.h"
+
+/*
+ * Convert from filesystem to in-memory representation.
+ */
+static struct posix_acl *
+ext4_acl_from_disk(const void *value, size_t size)
+{
+       const char *end = (char *)value + size;
+       int n, count;
+       struct posix_acl *acl;
+
+       if (!value)
+               return NULL;
+       if (size < sizeof(ext4_acl_header))
+                return ERR_PTR(-EINVAL);
+       if (((ext4_acl_header *)value)->a_version !=
+           cpu_to_le32(EXT4_ACL_VERSION))
+               return ERR_PTR(-EINVAL);
+       value = (char *)value + sizeof(ext4_acl_header);
+       count = ext4_acl_count(size);
+       if (count < 0)
+               return ERR_PTR(-EINVAL);
+       if (count == 0)
+               return NULL;
+       acl = posix_acl_alloc(count, GFP_KERNEL);
+       if (!acl)
+               return ERR_PTR(-ENOMEM);
+       for (n=0; n < count; n++) {
+               ext4_acl_entry *entry =
+                       (ext4_acl_entry *)value;
+               if ((char *)value + sizeof(ext4_acl_entry_short) > end)
+                       goto fail;
+               acl->a_entries[n].e_tag  = le16_to_cpu(entry->e_tag);
+               acl->a_entries[n].e_perm = le16_to_cpu(entry->e_perm);
+               switch(acl->a_entries[n].e_tag) {
+                       case ACL_USER_OBJ:
+                       case ACL_GROUP_OBJ:
+                       case ACL_MASK:
+                       case ACL_OTHER:
+                               value = (char *)value +
+                                       sizeof(ext4_acl_entry_short);
+                               acl->a_entries[n].e_id = ACL_UNDEFINED_ID;
+                               break;
+
+                       case ACL_USER:
+                       case ACL_GROUP:
+                               value = (char *)value + sizeof(ext4_acl_entry);
+                               if ((char *)value > end)
+                                       goto fail;
+                               acl->a_entries[n].e_id =
+                                       le32_to_cpu(entry->e_id);
+                               break;
+
+                       default:
+                               goto fail;
+               }
+       }
+       if (value != end)
+               goto fail;
+       return acl;
+
+fail:
+       posix_acl_release(acl);
+       return ERR_PTR(-EINVAL);
+}
+
+/*
+ * Convert from in-memory to filesystem representation.
+ */
+static void *
+ext4_acl_to_disk(const struct posix_acl *acl, size_t *size)
+{
+       ext4_acl_header *ext_acl;
+       char *e;
+       size_t n;
+
+       *size = ext4_acl_size(acl->a_count);
+       ext_acl = kmalloc(sizeof(ext4_acl_header) + acl->a_count *
+                       sizeof(ext4_acl_entry), GFP_KERNEL);
+       if (!ext_acl)
+               return ERR_PTR(-ENOMEM);
+       ext_acl->a_version = cpu_to_le32(EXT4_ACL_VERSION);
+       e = (char *)ext_acl + sizeof(ext4_acl_header);
+       for (n=0; n < acl->a_count; n++) {
+               ext4_acl_entry *entry = (ext4_acl_entry *)e;
+               entry->e_tag  = cpu_to_le16(acl->a_entries[n].e_tag);
+               entry->e_perm = cpu_to_le16(acl->a_entries[n].e_perm);
+               switch(acl->a_entries[n].e_tag) {
+                       case ACL_USER:
+                       case ACL_GROUP:
+                               entry->e_id =
+                                       cpu_to_le32(acl->a_entries[n].e_id);
+                               e += sizeof(ext4_acl_entry);
+                               break;
+
+                       case ACL_USER_OBJ:
+                       case ACL_GROUP_OBJ:
+                       case ACL_MASK:
+                       case ACL_OTHER:
+                               e += sizeof(ext4_acl_entry_short);
+                               break;
+
+                       default:
+                               goto fail;
+               }
+       }
+       return (char *)ext_acl;
+
+fail:
+       kfree(ext_acl);
+       return ERR_PTR(-EINVAL);
+}
+
+static inline struct posix_acl *
+ext4_iget_acl(struct inode *inode, struct posix_acl **i_acl)
+{
+       struct posix_acl *acl = EXT4_ACL_NOT_CACHED;
+
+       spin_lock(&inode->i_lock);
+       if (*i_acl != EXT4_ACL_NOT_CACHED)
+               acl = posix_acl_dup(*i_acl);
+       spin_unlock(&inode->i_lock);
+
+       return acl;
+}
+
+static inline void
+ext4_iset_acl(struct inode *inode, struct posix_acl **i_acl,
+               struct posix_acl *acl)
+{
+       spin_lock(&inode->i_lock);
+       if (*i_acl != EXT4_ACL_NOT_CACHED)
+               posix_acl_release(*i_acl);
+       *i_acl = posix_acl_dup(acl);
+       spin_unlock(&inode->i_lock);
+}
+
+/*
+ * Inode operation get_posix_acl().
+ *
+ * inode->i_mutex: don't care
+ */
+static struct posix_acl *
+ext4_get_acl(struct inode *inode, int type)
+{
+       struct ext4_inode_info *ei = EXT4_I(inode);
+       int name_index;
+       char *value = NULL;
+       struct posix_acl *acl;
+       int retval;
+
+       if (!test_opt(inode->i_sb, POSIX_ACL))
+               return NULL;
+
+       switch(type) {
+               case ACL_TYPE_ACCESS:
+                       acl = ext4_iget_acl(inode, &ei->i_acl);
+                       if (acl != EXT4_ACL_NOT_CACHED)
+                               return acl;
+                       name_index = EXT4_XATTR_INDEX_POSIX_ACL_ACCESS;
+                       break;
+
+               case ACL_TYPE_DEFAULT:
+                       acl = ext4_iget_acl(inode, &ei->i_default_acl);
+                       if (acl != EXT4_ACL_NOT_CACHED)
+                               return acl;
+                       name_index = EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT;
+                       break;
+
+               default:
+                       return ERR_PTR(-EINVAL);
+       }
+       retval = ext4_xattr_get(inode, name_index, "", NULL, 0);
+       if (retval > 0) {
+               value = kmalloc(retval, GFP_KERNEL);
+               if (!value)
+                       return ERR_PTR(-ENOMEM);
+               retval = ext4_xattr_get(inode, name_index, "", value, retval);
+       }
+       if (retval > 0)
+               acl = ext4_acl_from_disk(value, retval);
+       else if (retval == -ENODATA || retval == -ENOSYS)
+               acl = NULL;
+       else
+               acl = ERR_PTR(retval);
+       kfree(value);
+
+       if (!IS_ERR(acl)) {
+               switch(type) {
+                       case ACL_TYPE_ACCESS:
+                               ext4_iset_acl(inode, &ei->i_acl, acl);
+                               break;
+
+                       case ACL_TYPE_DEFAULT:
+                               ext4_iset_acl(inode, &ei->i_default_acl, acl);
+                               break;
+               }
+       }
+       return acl;
+}
+
+/*
+ * Set the access or default ACL of an inode.
+ *
+ * inode->i_mutex: down unless called from ext4_new_inode
+ */
+static int
+ext4_set_acl(handle_t *handle, struct inode *inode, int type,
+            struct posix_acl *acl)
+{
+       struct ext4_inode_info *ei = EXT4_I(inode);
+       int name_index;
+       void *value = NULL;
+       size_t size = 0;
+       int error;
+
+       if (S_ISLNK(inode->i_mode))
+               return -EOPNOTSUPP;
+
+       switch(type) {
+               case ACL_TYPE_ACCESS:
+                       name_index = EXT4_XATTR_INDEX_POSIX_ACL_ACCESS;
+                       if (acl) {
+                               mode_t mode = inode->i_mode;
+                               error = posix_acl_equiv_mode(acl, &mode);
+                               if (error < 0)
+                                       return error;
+                               else {
+                                       inode->i_mode = mode;
+                                       ext4_mark_inode_dirty(handle, inode);
+                                       if (error == 0)
+                                               acl = NULL;
+                               }
+                       }
+                       break;
+
+               case ACL_TYPE_DEFAULT:
+                       name_index = EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT;
+                       if (!S_ISDIR(inode->i_mode))
+                               return acl ? -EACCES : 0;
+                       break;
+
+               default:
+                       return -EINVAL;
+       }
+       if (acl) {
+               value = ext4_acl_to_disk(acl, &size);
+               if (IS_ERR(value))
+                       return (int)PTR_ERR(value);
+       }
+
+       error = ext4_xattr_set_handle(handle, inode, name_index, "",
+                                     value, size, 0);
+
+       kfree(value);
+       if (!error) {
+               switch(type) {
+                       case ACL_TYPE_ACCESS:
+                               ext4_iset_acl(inode, &ei->i_acl, acl);
+                               break;
+
+                       case ACL_TYPE_DEFAULT:
+                               ext4_iset_acl(inode, &ei->i_default_acl, acl);
+                               break;
+               }
+       }
+       return error;
+}
+
+static int
+ext4_check_acl(struct inode *inode, int mask)
+{
+       struct posix_acl *acl = ext4_get_acl(inode, ACL_TYPE_ACCESS);
+
+       if (IS_ERR(acl))
+               return PTR_ERR(acl);
+       if (acl) {
+               int error = posix_acl_permission(inode, acl, mask);
+               posix_acl_release(acl);
+               return error;
+       }
+
+       return -EAGAIN;
+}
+
+int
+ext4_permission(struct inode *inode, int mask, struct nameidata *nd)
+{
+       return generic_permission(inode, mask, ext4_check_acl);
+}
+
+/*
+ * Initialize the ACLs of a new inode. Called from ext4_new_inode.
+ *
+ * dir->i_mutex: down
+ * inode->i_mutex: up (access to inode is still exclusive)
+ */
+int
+ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
+{
+       struct posix_acl *acl = NULL;
+       int error = 0;
+
+       if (!S_ISLNK(inode->i_mode)) {
+               if (test_opt(dir->i_sb, POSIX_ACL)) {
+                       acl = ext4_get_acl(dir, ACL_TYPE_DEFAULT);
+                       if (IS_ERR(acl))
+                               return PTR_ERR(acl);
+               }
+               if (!acl)
+                       inode->i_mode &= ~current->fs->umask;
+       }
+       if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
+               struct posix_acl *clone;
+               mode_t mode;
+
+               if (S_ISDIR(inode->i_mode)) {
+                       error = ext4_set_acl(handle, inode,
+                                            ACL_TYPE_DEFAULT, acl);
+                       if (error)
+                               goto cleanup;
+               }
+               clone = posix_acl_clone(acl, GFP_KERNEL);
+               error = -ENOMEM;
+               if (!clone)
+                       goto cleanup;
+
+               mode = inode->i_mode;
+               error = posix_acl_create_masq(clone, &mode);
+               if (error >= 0) {
+                       inode->i_mode = mode;
+                       if (error > 0) {
+                               /* This is an extended ACL */
+                               error = ext4_set_acl(handle, inode,
+                                                    ACL_TYPE_ACCESS, clone);
+                       }
+               }
+               posix_acl_release(clone);
+       }
+cleanup:
+       posix_acl_release(acl);
+       return error;
+}
+
+/*
+ * Does chmod for an inode that may have an Access Control List. The
+ * inode->i_mode field must be updated to the desired value by the caller
+ * before calling this function.
+ * Returns 0 on success, or a negative error number.
+ *
+ * We change the ACL rather than storing some ACL entries in the file
+ * mode permission bits (which would be more efficient), because that
+ * would break once additional permissions (like  ACL_APPEND, ACL_DELETE
+ * for directories) are added. There are no more bits available in the
+ * file mode.
+ *
+ * inode->i_mutex: down
+ */
+int
+ext4_acl_chmod(struct inode *inode)
+{
+       struct posix_acl *acl, *clone;
+       int error;
+
+       if (S_ISLNK(inode->i_mode))
+               return -EOPNOTSUPP;
+       if (!test_opt(inode->i_sb, POSIX_ACL))
+               return 0;
+       acl = ext4_get_acl(inode, ACL_TYPE_ACCESS);
+       if (IS_ERR(acl) || !acl)
+               return PTR_ERR(acl);
+       clone = posix_acl_clone(acl, GFP_KERNEL);
+       posix_acl_release(acl);
+       if (!clone)
+               return -ENOMEM;
+       error = posix_acl_chmod_masq(clone, inode->i_mode);
+       if (!error) {
+               handle_t *handle;
+               int retries = 0;
+
+       retry:
+               handle = ext4_journal_start(inode,
+                               EXT4_DATA_TRANS_BLOCKS(inode->i_sb));
+               if (IS_ERR(handle)) {
+                       error = PTR_ERR(handle);
+                       ext4_std_error(inode->i_sb, error);
+                       goto out;
+               }
+               error = ext4_set_acl(handle, inode, ACL_TYPE_ACCESS, clone);
+               ext4_journal_stop(handle);
+               if (error == -ENOSPC &&
+                   ext4_should_retry_alloc(inode->i_sb, &retries))
+                       goto retry;
+       }
+out:
+       posix_acl_release(clone);
+       return error;
+}
+
+/*
+ * Extended attribute handlers
+ */
+static size_t
+ext4_xattr_list_acl_access(struct inode *inode, char *list, size_t list_len,
+                          const char *name, size_t name_len)
+{
+       const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS);
+
+       if (!test_opt(inode->i_sb, POSIX_ACL))
+               return 0;
+       if (list && size <= list_len)
+               memcpy(list, POSIX_ACL_XATTR_ACCESS, size);
+       return size;
+}
+
+static size_t
+ext4_xattr_list_acl_default(struct inode *inode, char *list, size_t list_len,
+                           const char *name, size_t name_len)
+{
+       const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT);
+
+       if (!test_opt(inode->i_sb, POSIX_ACL))
+               return 0;
+       if (list && size <= list_len)
+               memcpy(list, POSIX_ACL_XATTR_DEFAULT, size);
+       return size;
+}
+
+static int
+ext4_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size)
+{
+       struct posix_acl *acl;
+       int error;
+
+       if (!test_opt(inode->i_sb, POSIX_ACL))
+               return -EOPNOTSUPP;
+
+       acl = ext4_get_acl(inode, type);
+       if (IS_ERR(acl))
+               return PTR_ERR(acl);
+       if (acl == NULL)
+               return -ENODATA;
+       error = posix_acl_to_xattr(acl, buffer, size);
+       posix_acl_release(acl);
+
+       return error;
+}
+
+static int
+ext4_xattr_get_acl_access(struct inode *inode, const char *name,
+                         void *buffer, size_t size)
+{
+       if (strcmp(name, "") != 0)
+               return -EINVAL;
+       return ext4_xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size);
+}
+
+static int
+ext4_xattr_get_acl_default(struct inode *inode, const char *name,
+                          void *buffer, size_t size)
+{
+       if (strcmp(name, "") != 0)
+               return -EINVAL;
+       return ext4_xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size);
+}
+
+static int
+ext4_xattr_set_acl(struct inode *inode, int type, const void *value,
+                  size_t size)
+{
+       handle_t *handle;
+       struct posix_acl *acl;
+       int error, retries = 0;
+
+       if (!test_opt(inode->i_sb, POSIX_ACL))
+               return -EOPNOTSUPP;
+       if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
+               return -EPERM;
+
+       if (value) {
+               acl = posix_acl_from_xattr(value, size);
+               if (IS_ERR(acl))
+                       return PTR_ERR(acl);
+               else if (acl) {
+                       error = posix_acl_valid(acl);
+                       if (error)
+                               goto release_and_out;
+               }
+       } else
+               acl = NULL;
+
+retry:
+       handle = ext4_journal_start(inode, EXT4_DATA_TRANS_BLOCKS(inode->i_sb));
+       if (IS_ERR(handle))
+               return PTR_ERR(handle);
+       error = ext4_set_acl(handle, inode, type, acl);
+       ext4_journal_stop(handle);
+       if (error == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
+               goto retry;
+
+release_and_out:
+       posix_acl_release(acl);
+       return error;
+}
+
+static int
+ext4_xattr_set_acl_access(struct inode *inode, const char *name,
+                         const void *value, size_t size, int flags)
+{
+       if (strcmp(name, "") != 0)
+               return -EINVAL;
+       return ext4_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size);
+}
+
+static int
+ext4_xattr_set_acl_default(struct inode *inode, const char *name,
+                          const void *value, size_t size, int flags)
+{
+       if (strcmp(name, "") != 0)
+               return -EINVAL;
+       return ext4_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size);
+}
+
+struct xattr_handler ext4_xattr_acl_access_handler = {
+       .prefix = POSIX_ACL_XATTR_ACCESS,
+       .list   = ext4_xattr_list_acl_access,
+       .get    = ext4_xattr_get_acl_access,
+       .set    = ext4_xattr_set_acl_access,
+};
+
+struct xattr_handler ext4_xattr_acl_default_handler = {
+       .prefix = POSIX_ACL_XATTR_DEFAULT,
+       .list   = ext4_xattr_list_acl_default,
+       .get    = ext4_xattr_get_acl_default,
+       .set    = ext4_xattr_set_acl_default,
+};
diff --git a/fs/ext4/acl.h b/fs/ext4/acl.h
new file mode 100644 (file)
index 0000000..26a5c1a
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+  File: fs/ext4/acl.h
+
+  (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
+*/
+
+#include <linux/posix_acl_xattr.h>
+
+#define EXT4_ACL_VERSION       0x0001
+
+typedef struct {
+       __le16          e_tag;
+       __le16          e_perm;
+       __le32          e_id;
+} ext4_acl_entry;
+
+typedef struct {
+       __le16          e_tag;
+       __le16          e_perm;
+} ext4_acl_entry_short;
+
+typedef struct {
+       __le32          a_version;
+} ext4_acl_header;
+
+static inline size_t ext4_acl_size(int count)
+{
+       if (count <= 4) {
+               return sizeof(ext4_acl_header) +
+                      count * sizeof(ext4_acl_entry_short);
+       } else {
+               return sizeof(ext4_acl_header) +
+                      4 * sizeof(ext4_acl_entry_short) +
+                      (count - 4) * sizeof(ext4_acl_entry);
+       }
+}
+
+static inline int ext4_acl_count(size_t size)
+{
+       ssize_t s;
+       size -= sizeof(ext4_acl_header);
+       s = size - 4 * sizeof(ext4_acl_entry_short);
+       if (s < 0) {
+               if (size % sizeof(ext4_acl_entry_short))
+                       return -1;
+               return size / sizeof(ext4_acl_entry_short);
+       } else {
+               if (s % sizeof(ext4_acl_entry))
+                       return -1;
+               return s / sizeof(ext4_acl_entry) + 4;
+       }
+}
+
+#ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
+
+/* Value for inode->u.ext4_i.i_acl and inode->u.ext4_i.i_default_acl
+   if the ACL has not been cached */
+#define EXT4_ACL_NOT_CACHED ((void *)-1)
+
+/* acl.c */
+extern int ext4_permission (struct inode *, int, struct nameidata *);
+extern int ext4_acl_chmod (struct inode *);
+extern int ext4_init_acl (handle_t *, struct inode *, struct inode *);
+
+#else  /* CONFIG_EXT4DEV_FS_POSIX_ACL */
+#include <linux/sched.h>
+#define ext4_permission NULL
+
+static inline int
+ext4_acl_chmod(struct inode *inode)
+{
+       return 0;
+}
+
+static inline int
+ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
+{
+       return 0;
+}
+#endif  /* CONFIG_EXT4DEV_FS_POSIX_ACL */
+
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
new file mode 100644 (file)
index 0000000..5d45582
--- /dev/null
@@ -0,0 +1,1833 @@
+/*
+ *  linux/fs/ext4/balloc.c
+ *
+ * Copyright (C) 1992, 1993, 1994, 1995
+ * Remy Card (card@masi.ibp.fr)
+ * Laboratoire MASI - Institut Blaise Pascal
+ * Universite Pierre et Marie Curie (Paris VI)
+ *
+ *  Enhanced block allocation by Stephen Tweedie (sct@redhat.com), 1993
+ *  Big-endian to little-endian byte-swapping/bitmaps by
+ *        David S. Miller (davem@caip.rutgers.edu), 1995
+ */
+
+#include <linux/time.h>
+#include <linux/capability.h>
+#include <linux/fs.h>
+#include <linux/jbd2.h>
+#include <linux/ext4_fs.h>
+#include <linux/ext4_jbd2.h>
+#include <linux/quotaops.h>
+#include <linux/buffer_head.h>
+
+/*
+ * balloc.c contains the blocks allocation and deallocation routines
+ */
+
+/*
+ * Calculate the block group number and offset, given a block number
+ */
+void ext4_get_group_no_and_offset(struct super_block *sb, ext4_fsblk_t blocknr,
+               unsigned long *blockgrpp, ext4_grpblk_t *offsetp)
+{
+        struct ext4_super_block *es = EXT4_SB(sb)->s_es;
+       ext4_grpblk_t offset;
+
+        blocknr = blocknr - le32_to_cpu(es->s_first_data_block);
+       offset = do_div(blocknr, EXT4_BLOCKS_PER_GROUP(sb));
+       if (offsetp)
+               *offsetp = offset;
+       if (blockgrpp)
+               *blockgrpp = blocknr;
+
+}
+
+/*
+ * The free blocks are managed by bitmaps.  A file system contains several
+ * blocks groups.  Each group contains 1 bitmap block for blocks, 1 bitmap
+ * block for inodes, N blocks for the inode table and data blocks.
+ *
+ * The file system contains group descriptors which are located after the
+ * super block.  Each descriptor contains the number of the bitmap block and
+ * the free blocks count in the block.  The descriptors are loaded in memory
+ * when a file system is mounted (see ext4_read_super).
+ */
+
+
+#define in_range(b, first, len)        ((b) >= (first) && (b) <= (first) + (len) - 1)
+
+/**
+ * ext4_get_group_desc() -- load group descriptor from disk
+ * @sb:                        super block
+ * @block_group:       given block group
+ * @bh:                        pointer to the buffer head to store the block
+ *                     group descriptor
+ */
+struct ext4_group_desc * ext4_get_group_desc(struct super_block * sb,
+                                            unsigned int block_group,
+                                            struct buffer_head ** bh)
+{
+       unsigned long group_desc;
+       unsigned long offset;
+       struct ext4_group_desc * desc;
+       struct ext4_sb_info *sbi = EXT4_SB(sb);
+
+       if (block_group >= sbi->s_groups_count) {
+               ext4_error (sb, "ext4_get_group_desc",
+                           "block_group >= groups_count - "
+                           "block_group = %d, groups_count = %lu",
+                           block_group, sbi->s_groups_count);
+
+               return NULL;
+       }
+       smp_rmb();
+
+       group_desc = block_group >> EXT4_DESC_PER_BLOCK_BITS(sb);
+       offset = block_group & (EXT4_DESC_PER_BLOCK(sb) - 1);
+       if (!sbi->s_group_desc[group_desc]) {
+               ext4_error (sb, "ext4_get_group_desc",
+                           "Group descriptor not loaded - "
+                           "block_group = %d, group_desc = %lu, desc = %lu",
+                            block_group, group_desc, offset);
+               return NULL;
+       }
+
+       desc = (struct ext4_group_desc *)(
+               (__u8 *)sbi->s_group_desc[group_desc]->b_data +
+               offset * EXT4_DESC_SIZE(sb));
+       if (bh)
+               *bh = sbi->s_group_desc[group_desc];
+       return desc;
+}
+
+/**
+ * read_block_bitmap()
+ * @sb:                        super block
+ * @block_group:       given block group
+ *
+ * Read the bitmap for a given block_group, reading into the specified
+ * slot in the superblock's bitmap cache.
+ *
+ * Return buffer_head on success or NULL in case of failure.
+ */
+static struct buffer_head *
+read_block_bitmap(struct super_block *sb, unsigned int block_group)
+{
+       struct ext4_group_desc * desc;
+       struct buffer_head * bh = NULL;
+
+       desc = ext4_get_group_desc (sb, block_group, NULL);
+       if (!desc)
+               goto error_out;
+       bh = sb_bread(sb, ext4_block_bitmap(sb, desc));
+       if (!bh)
+               ext4_error (sb, "read_block_bitmap",
+                           "Cannot read block bitmap - "
+                           "block_group = %d, block_bitmap = %llu",
+                           block_group,
+                           ext4_block_bitmap(sb, desc));
+error_out:
+       return bh;
+}
+/*
+ * The reservation window structure operations
+ * --------------------------------------------
+ * Operations include:
+ * dump, find, add, remove, is_empty, find_next_reservable_window, etc.
+ *
+ * We use a red-black tree to represent per-filesystem reservation
+ * windows.
+ *
+ */
+
+/**
+ * __rsv_window_dump() -- Dump the filesystem block allocation reservation map
+ * @rb_root:           root of per-filesystem reservation rb tree
+ * @verbose:           verbose mode
+ * @fn:                        function which wishes to dump the reservation map
+ *
+ * If verbose is turned on, it will print the whole block reservation
+ * windows(start, end).        Otherwise, it will only print out the "bad" windows,
+ * those windows that overlap with their immediate neighbors.
+ */
+#if 1
+static void __rsv_window_dump(struct rb_root *root, int verbose,
+                             const char *fn)
+{
+       struct rb_node *n;
+       struct ext4_reserve_window_node *rsv, *prev;
+       int bad;
+
+restart:
+       n = rb_first(root);
+       bad = 0;
+       prev = NULL;
+
+       printk("Block Allocation Reservation Windows Map (%s):\n", fn);
+       while (n) {
+               rsv = list_entry(n, struct ext4_reserve_window_node, rsv_node);
+               if (verbose)
+                       printk("reservation window 0x%p "
+                              "start:  %llu, end:  %llu\n",
+                              rsv, rsv->rsv_start, rsv->rsv_end);
+               if (rsv->rsv_start && rsv->rsv_start >= rsv->rsv_end) {
+                       printk("Bad reservation %p (start >= end)\n",
+                              rsv);
+                       bad = 1;
+               }
+               if (prev && prev->rsv_end >= rsv->rsv_start) {
+                       printk("Bad reservation %p (prev->end >= start)\n",
+                              rsv);
+                       bad = 1;
+               }
+               if (bad) {
+                       if (!verbose) {
+                               printk("Restarting reservation walk in verbose mode\n");
+                               verbose = 1;
+                               goto restart;
+                       }
+               }
+               n = rb_next(n);
+               prev = rsv;
+       }
+       printk("Window map complete.\n");
+       if (bad)
+               BUG();
+}
+#define rsv_window_dump(root, verbose) \
+       __rsv_window_dump((root), (verbose), __FUNCTION__)
+#else
+#define rsv_window_dump(root, verbose) do {} while (0)
+#endif
+
+/**
+ * goal_in_my_reservation()
+ * @rsv:               inode's reservation window
+ * @grp_goal:          given goal block relative to the allocation block group
+ * @group:             the current allocation block group
+ * @sb:                        filesystem super block
+ *
+ * Test if the given goal block (group relative) is within the file's
+ * own block reservation window range.
+ *
+ * If the reservation window is outside the goal allocation group, return 0;
+ * grp_goal (given goal block) could be -1, which means no specific
+ * goal block. In this case, always return 1.
+ * If the goal block is within the reservation window, return 1;
+ * otherwise, return 0;
+ */
+static int
+goal_in_my_reservation(struct ext4_reserve_window *rsv, ext4_grpblk_t grp_goal,
+                       unsigned int group, struct super_block * sb)
+{
+       ext4_fsblk_t group_first_block, group_last_block;
+
+       group_first_block = ext4_group_first_block_no(sb, group);
+       group_last_block = group_first_block + (EXT4_BLOCKS_PER_GROUP(sb) - 1);
+
+       if ((rsv->_rsv_start > group_last_block) ||
+           (rsv->_rsv_end < group_first_block))
+               return 0;
+       if ((grp_goal >= 0) && ((grp_goal + group_first_block < rsv->_rsv_start)
+               || (grp_goal + group_first_block > rsv->_rsv_end)))
+               return 0;
+       return 1;
+}
+
+/**
+ * search_reserve_window()
+ * @rb_root:           root of reservation tree
+ * @goal:              target allocation block
+ *
+ * Find the reserved window which includes the goal, or the previous one
+ * if the goal is not in any window.
+ * Returns NULL if there are no windows or if all windows start after the goal.
+ */
+static struct ext4_reserve_window_node *
+search_reserve_window(struct rb_root *root, ext4_fsblk_t goal)
+{
+       struct rb_node *n = root->rb_node;
+       struct ext4_reserve_window_node *rsv;
+
+       if (!n)
+               return NULL;
+
+       do {
+               rsv = rb_entry(n, struct ext4_reserve_window_node, rsv_node);
+
+               if (goal < rsv->rsv_start)
+                       n = n->rb_left;
+               else if (goal > rsv->rsv_end)
+                       n = n->rb_right;
+               else
+                       return rsv;
+       } while (n);
+       /*
+        * We've fallen off the end of the tree: the goal wasn't inside
+        * any particular node.  OK, the previous node must be to one
+        * side of the interval containing the goal.  If it's the RHS,
+        * we need to back up one.
+        */
+       if (rsv->rsv_start > goal) {
+               n = rb_prev(&rsv->rsv_node);
+               rsv = rb_entry(n, struct ext4_reserve_window_node, rsv_node);
+       }
+       return rsv;
+}
+
+/**
+ * ext4_rsv_window_add() -- Insert a window to the block reservation rb tree.
+ * @sb:                        super block
+ * @rsv:               reservation window to add
+ *
+ * Must be called with rsv_lock hold.
+ */
+void ext4_rsv_window_add(struct super_block *sb,
+                   struct ext4_reserve_window_node *rsv)
+{
+       struct rb_root *root = &EXT4_SB(sb)->s_rsv_window_root;
+       struct rb_node *node = &rsv->rsv_node;
+       ext4_fsblk_t start = rsv->rsv_start;
+
+       struct rb_node ** p = &root->rb_node;
+       struct rb_node * parent = NULL;
+       struct ext4_reserve_window_node *this;
+
+       while (*p)
+       {
+               parent = *p;
+               this = rb_entry(parent, struct ext4_reserve_window_node, rsv_node);
+
+               if (start < this->rsv_start)
+                       p = &(*p)->rb_left;
+               else if (start > this->rsv_end)
+                       p = &(*p)->rb_right;
+               else {
+                       rsv_window_dump(root, 1);
+                       BUG();
+               }
+       }
+
+       rb_link_node(node, parent, p);
+       rb_insert_color(node, root);
+}
+
+/**
+ * ext4_rsv_window_remove() -- unlink a window from the reservation rb tree
+ * @sb:                        super block
+ * @rsv:               reservation window to remove
+ *
+ * Mark the block reservation window as not allocated, and unlink it
+ * from the filesystem reservation window rb tree. Must be called with
+ * rsv_lock hold.
+ */
+static void rsv_window_remove(struct super_block *sb,
+                             struct ext4_reserve_window_node *rsv)
+{
+       rsv->rsv_start = EXT4_RESERVE_WINDOW_NOT_ALLOCATED;
+       rsv->rsv_end = EXT4_RESERVE_WINDOW_NOT_ALLOCATED;
+       rsv->rsv_alloc_hit = 0;
+       rb_erase(&rsv->rsv_node, &EXT4_SB(sb)->s_rsv_window_root);
+}
+
+/*
+ * rsv_is_empty() -- Check if the reservation window is allocated.
+ * @rsv:               given reservation window to check
+ *
+ * returns 1 if the end block is EXT4_RESERVE_WINDOW_NOT_ALLOCATED.
+ */
+static inline int rsv_is_empty(struct ext4_reserve_window *rsv)
+{
+       /* a valid reservation end block could not be 0 */
+       return rsv->_rsv_end == EXT4_RESERVE_WINDOW_NOT_ALLOCATED;
+}
+
+/**
+ * ext4_init_block_alloc_info()
+ * @inode:             file inode structure
+ *
+ * Allocate and initialize the reservation window structure, and
+ * link the window to the ext4 inode structure at last
+ *
+ * The reservation window structure is only dynamically allocated
+ * and linked to ext4 inode the first time the open file
+ * needs a new block. So, before every ext4_new_block(s) call, for
+ * regular files, we should check whether the reservation window
+ * structure exists or not. In the latter case, this function is called.
+ * Fail to do so will result in block reservation being turned off for that
+ * open file.
+ *
+ * This function is called from ext4_get_blocks_handle(), also called
+ * when setting the reservation window size through ioctl before the file
+ * is open for write (needs block allocation).
+ *
+ * Needs truncate_mutex protection prior to call this function.
+ */
+void ext4_init_block_alloc_info(struct inode *inode)
+{
+       struct ext4_inode_info *ei = EXT4_I(inode);
+       struct ext4_block_alloc_info *block_i = ei->i_block_alloc_info;
+       struct super_block *sb = inode->i_sb;
+
+       block_i = kmalloc(sizeof(*block_i), GFP_NOFS);
+       if (block_i) {
+               struct ext4_reserve_window_node *rsv = &block_i->rsv_window_node;
+
+               rsv->rsv_start = EXT4_RESERVE_WINDOW_NOT_ALLOCATED;
+               rsv->rsv_end = EXT4_RESERVE_WINDOW_NOT_ALLOCATED;
+
+               /*
+                * if filesystem is mounted with NORESERVATION, the goal
+                * reservation window size is set to zero to indicate
+                * block reservation is off
+                */
+               if (!test_opt(sb, RESERVATION))
+                       rsv->rsv_goal_size = 0;
+               else
+                       rsv->rsv_goal_size = EXT4_DEFAULT_RESERVE_BLOCKS;
+               rsv->rsv_alloc_hit = 0;
+               block_i->last_alloc_logical_block = 0;
+               block_i->last_alloc_physical_block = 0;
+       }
+       ei->i_block_alloc_info = block_i;
+}
+
+/**
+ * ext4_discard_reservation()
+ * @inode:             inode
+ *
+ * Discard(free) block reservation window on last file close, or truncate
+ * or at last iput().
+ *
+ * It is being called in three cases:
+ *     ext4_release_file(): last writer close the file
+ *     ext4_clear_inode(): last iput(), when nobody link to this file.
+ *     ext4_truncate(): when the block indirect map is about to change.
+ *
+ */
+void ext4_discard_reservation(struct inode *inode)
+{
+       struct ext4_inode_info *ei = EXT4_I(inode);
+       struct ext4_block_alloc_info *block_i = ei->i_block_alloc_info;
+       struct ext4_reserve_window_node *rsv;
+       spinlock_t *rsv_lock = &EXT4_SB(inode->i_sb)->s_rsv_window_lock;
+
+       if (!block_i)
+               return;
+
+       rsv = &block_i->rsv_window_node;
+       if (!rsv_is_empty(&rsv->rsv_window)) {
+               spin_lock(rsv_lock);
+               if (!rsv_is_empty(&rsv->rsv_window))
+                       rsv_window_remove(inode->i_sb, rsv);
+               spin_unlock(rsv_lock);
+       }
+}
+
+/**
+ * ext4_free_blocks_sb() -- Free given blocks and update quota
+ * @handle:                    handle to this transaction
+ * @sb:                                super block
+ * @block:                     start physcial block to free
+ * @count:                     number of blocks to free
+ * @pdquot_freed_blocks:       pointer to quota
+ */
+void ext4_free_blocks_sb(handle_t *handle, struct super_block *sb,
+                        ext4_fsblk_t block, unsigned long count,
+                        unsigned long *pdquot_freed_blocks)
+{
+       struct buffer_head *bitmap_bh = NULL;
+       struct buffer_head *gd_bh;
+       unsigned long block_group;
+       ext4_grpblk_t bit;
+       unsigned long i;
+       unsigned long overflow;
+       struct ext4_group_desc * desc;
+       struct ext4_super_block * es;
+       struct ext4_sb_info *sbi;
+       int err = 0, ret;
+       ext4_grpblk_t group_freed;
+
+       *pdquot_freed_blocks = 0;
+       sbi = EXT4_SB(sb);
+       es = sbi->s_es;
+       if (block < le32_to_cpu(es->s_first_data_block) ||
+           block + count < block ||
+           block + count > ext4_blocks_count(es)) {
+               ext4_error (sb, "ext4_free_blocks",
+                           "Freeing blocks not in datazone - "
+                           "block = %llu, count = %lu", block, count);
+               goto error_return;
+       }
+
+       ext4_debug ("freeing block(s) %llu-%llu\n", block, block + count - 1);
+
+do_more:
+       overflow = 0;
+       ext4_get_group_no_and_offset(sb, block, &block_group, &bit);
+       /*
+        * Check to see if we are freeing blocks across a group
+        * boundary.
+        */
+       if (bit + count > EXT4_BLOCKS_PER_GROUP(sb)) {
+               overflow = bit + count - EXT4_BLOCKS_PER_GROUP(sb);
+               count -= overflow;
+       }
+       brelse(bitmap_bh);
+       bitmap_bh = read_block_bitmap(sb, block_group);
+       if (!bitmap_bh)
+               goto error_return;
+       desc = ext4_get_group_desc (sb, block_group, &gd_bh);
+       if (!desc)
+               goto error_return;
+
+       if (in_range(ext4_block_bitmap(sb, desc), block, count) ||
+           in_range(ext4_inode_bitmap(sb, desc), block, count) ||
+           in_range(block, ext4_inode_table(sb, desc), sbi->s_itb_per_group) ||
+           in_range(block + count - 1, ext4_inode_table(sb, desc),
+                    sbi->s_itb_per_group))
+               ext4_error (sb, "ext4_free_blocks",
+                           "Freeing blocks in system zones - "
+                           "Block = %llu, count = %lu",
+                           block, count);
+
+       /*
+        * We are about to start releasing blocks in the bitmap,
+        * so we need undo access.
+        */
+       /* @@@ check errors */
+       BUFFER_TRACE(bitmap_bh, "getting undo access");
+       err = ext4_journal_get_undo_access(handle, bitmap_bh);
+       if (err)
+               goto error_return;
+
+       /*
+        * We are about to modify some metadata.  Call the journal APIs
+        * to unshare ->b_data if a currently-committing transaction is
+        * using it
+        */
+       BUFFER_TRACE(gd_bh, "get_write_access");
+       err = ext4_journal_get_write_access(handle, gd_bh);
+       if (err)
+               goto error_return;
+
+       jbd_lock_bh_state(bitmap_bh);
+
+       for (i = 0, group_freed = 0; i < count; i++) {
+               /*
+                * An HJ special.  This is expensive...
+                */
+#ifdef CONFIG_JBD_DEBUG
+               jbd_unlock_bh_state(bitmap_bh);
+               {
+                       struct buffer_head *debug_bh;
+                       debug_bh = sb_find_get_block(sb, block + i);
+                       if (debug_bh) {
+                               BUFFER_TRACE(debug_bh, "Deleted!");
+                               if (!bh2jh(bitmap_bh)->b_committed_data)
+                                       BUFFER_TRACE(debug_bh,
+                                               "No commited data in bitmap");
+                               BUFFER_TRACE2(debug_bh, bitmap_bh, "bitmap");
+                               __brelse(debug_bh);
+                       }
+               }
+               jbd_lock_bh_state(bitmap_bh);
+#endif
+               if (need_resched()) {
+                       jbd_unlock_bh_state(bitmap_bh);
+                       cond_resched();
+                       jbd_lock_bh_state(bitmap_bh);
+               }
+               /* @@@ This prevents newly-allocated data from being
+                * freed and then reallocated within the same
+                * transaction.
+                *
+                * Ideally we would want to allow that to happen, but to
+                * do so requires making jbd2_journal_forget() capable of
+                * revoking the queued write of a data block, which
+                * implies blocking on the journal lock.  *forget()
+                * cannot block due to truncate races.
+                *
+                * Eventually we can fix this by making jbd2_journal_forget()
+                * return a status indicating whether or not it was able
+                * to revoke the buffer.  On successful revoke, it is
+                * safe not to set the allocation bit in the committed
+                * bitmap, because we know that there is no outstanding
+                * activity on the buffer any more and so it is safe to
+                * reallocate it.
+                */
+               BUFFER_TRACE(bitmap_bh, "set in b_committed_data");
+               J_ASSERT_BH(bitmap_bh,
+                               bh2jh(bitmap_bh)->b_committed_data != NULL);
+               ext4_set_bit_atomic(sb_bgl_lock(sbi, block_group), bit + i,
+                               bh2jh(bitmap_bh)->b_committed_data);
+
+               /*
+                * We clear the bit in the bitmap after setting the committed
+                * data bit, because this is the reverse order to that which
+                * the allocator uses.
+                */
+               BUFFER_TRACE(bitmap_bh, "clear bit");
+               if (!ext4_clear_bit_atomic(sb_bgl_lock(sbi, block_group),
+                                               bit + i, bitmap_bh->b_data)) {
+                       jbd_unlock_bh_state(bitmap_bh);
+                       ext4_error(sb, __FUNCTION__,
+                                  "bit already cleared for block %llu",
+                                  (ext4_fsblk_t)(block + i));
+                       jbd_lock_bh_state(bitmap_bh);
+                       BUFFER_TRACE(bitmap_bh, "bit already cleared");
+               } else {
+                       group_freed++;
+               }
+       }
+       jbd_unlock_bh_state(bitmap_bh);
+
+       spin_lock(sb_bgl_lock(sbi, block_group));
+       desc->bg_free_blocks_count =
+               cpu_to_le16(le16_to_cpu(desc->bg_free_blocks_count) +
+                       group_freed);
+       spin_unlock(sb_bgl_lock(sbi, block_group));
+       percpu_counter_mod(&sbi->s_freeblocks_counter, count);
+
+       /* We dirtied the bitmap block */
+       BUFFER_TRACE(bitmap_bh, "dirtied bitmap block");
+       err = ext4_journal_dirty_metadata(handle, bitmap_bh);
+
+       /* And the group descriptor block */
+       BUFFER_TRACE(gd_bh, "dirtied group descriptor block");
+       ret = ext4_journal_dirty_metadata(handle, gd_bh);
+       if (!err) err = ret;
+       *pdquot_freed_blocks += group_freed;
+
+       if (overflow && !err) {
+               block += count;
+               count = overflow;
+               goto do_more;
+       }
+       sb->s_dirt = 1;
+error_return:
+       brelse(bitmap_bh);
+       ext4_std_error(sb, err);
+       return;
+}
+
+/**
+ * ext4_free_blocks() -- Free given blocks and update quota
+ * @handle:            handle for this transaction
+ * @inode:             inode
+ * @block:             start physical block to free
+ * @count:             number of blocks to count
+ */
+void ext4_free_blocks(handle_t *handle, struct inode *inode,
+                       ext4_fsblk_t block, unsigned long count)
+{
+       struct super_block * sb;
+       unsigned long dquot_freed_blocks;
+
+       sb = inode->i_sb;
+       if (!sb) {
+               printk ("ext4_free_blocks: nonexistent device");
+               return;
+       }
+       ext4_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
+       if (dquot_freed_blocks)
+               DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
+       return;
+}
+
+/**
+ * ext4_test_allocatable()
+ * @nr:                        given allocation block group
+ * @bh:                        bufferhead contains the bitmap of the given block group
+ *
+ * For ext4 allocations, we must not reuse any blocks which are
+ * allocated in the bitmap buffer's "last committed data" copy.  This
+ * prevents deletes from freeing up the page for reuse until we have
+ * committed the delete transaction.
+ *
+ * If we didn't do this, then deleting something and reallocating it as
+ * data would allow the old block to be overwritten before the
+ * transaction committed (because we force data to disk before commit).
+ * This would lead to corruption if we crashed between overwriting the
+ * data and committing the delete.
+ *
+ * @@@ We may want to make this allocation behaviour conditional on
+ * data-writes at some point, and disable it for metadata allocations or
+ * sync-data inodes.
+ */
+static int ext4_test_allocatable(ext4_grpblk_t nr, struct buffer_head *bh)
+{
+       int ret;
+       struct journal_head *jh = bh2jh(bh);
+
+       if (ext4_test_bit(nr, bh->b_data))
+               return 0;
+
+       jbd_lock_bh_state(bh);
+       if (!jh->b_committed_data)
+               ret = 1;
+       else
+               ret = !ext4_test_bit(nr, jh->b_committed_data);
+       jbd_unlock_bh_state(bh);
+       return ret;
+}
+
+/**
+ * bitmap_search_next_usable_block()
+ * @start:             the starting block (group relative) of the search
+ * @bh:                        bufferhead contains the block group bitmap
+ * @maxblocks:         the ending block (group relative) of the reservation
+ *
+ * The bitmap search --- search forward alternately through the actual
+ * bitmap on disk and the last-committed copy in journal, until we find a
+ * bit free in both bitmaps.
+ */
+static ext4_grpblk_t
+bitmap_search_next_usable_block(ext4_grpblk_t start, struct buffer_head *bh,
+                                       ext4_grpblk_t maxblocks)
+{
+       ext4_grpblk_t next;
+       struct journal_head *jh = bh2jh(bh);
+
+       while (start < maxblocks) {
+               next = ext4_find_next_zero_bit(bh->b_data, maxblocks, start);
+               if (next >= maxblocks)
+                       return -1;
+               if (ext4_test_allocatable(next, bh))
+                       return next;
+               jbd_lock_bh_state(bh);
+               if (jh->b_committed_data)
+                       start = ext4_find_next_zero_bit(jh->b_committed_data,
+                                                       maxblocks, next);
+               jbd_unlock_bh_state(bh);
+       }
+       return -1;
+}
+
+/**
+ * find_next_usable_block()
+ * @start:             the starting block (group relative) to find next
+ *                     allocatable block in bitmap.
+ * @bh:                        bufferhead contains the block group bitmap
+ * @maxblocks:         the ending block (group relative) for the search
+ *
+ * Find an allocatable block in a bitmap.  We honor both the bitmap and
+ * its last-committed copy (if that exists), and perform the "most
+ * appropriate allocation" algorithm of looking for a free block near
+ * the initial goal; then for a free byte somewhere in the bitmap; then
+ * for any free bit in the bitmap.
+ */
+static ext4_grpblk_t
+find_next_usable_block(ext4_grpblk_t start, struct buffer_head *bh,
+                       ext4_grpblk_t maxblocks)
+{
+       ext4_grpblk_t here, next;
+       char *p, *r;
+
+       if (start > 0) {
+               /*
+                * The goal was occupied; search forward for a free
+                * block within the next XX blocks.
+                *
+                * end_goal is more or less random, but it has to be
+                * less than EXT4_BLOCKS_PER_GROUP. Aligning up to the
+                * next 64-bit boundary is simple..
+                */
+               ext4_grpblk_t end_goal = (start + 63) & ~63;
+               if (end_goal > maxblocks)
+                       end_goal = maxblocks;
+               here = ext4_find_next_zero_bit(bh->b_data, end_goal, start);
+               if (here < end_goal && ext4_test_allocatable(here, bh))
+                       return here;
+               ext4_debug("Bit not found near goal\n");
+       }
+
+       here = start;
+       if (here < 0)
+               here = 0;
+
+       p = ((char *)bh->b_data) + (here >> 3);
+       r = memscan(p, 0, (maxblocks - here + 7) >> 3);
+       next = (r - ((char *)bh->b_data)) << 3;
+
+       if (next < maxblocks && next >= start && ext4_test_allocatable(next, bh))
+               return next;
+
+       /*
+        * The bitmap search --- search forward alternately through the actual
+        * bitmap and the last-committed copy until we find a bit free in
+        * both
+        */
+       here = bitmap_search_next_usable_block(here, bh, maxblocks);
+       return here;
+}
+
+/**
+ * claim_block()
+ * @block:             the free block (group relative) to allocate
+ * @bh:                        the bufferhead containts the block group bitmap
+ *
+ * We think we can allocate this block in this bitmap.  Try to set the bit.
+ * If that succeeds then check that nobody has allocated and then freed the
+ * block since we saw that is was not marked in b_committed_data.  If it _was_
+ * allocated and freed then clear the bit in the bitmap again and return
+ * zero (failure).
+ */
+static inline int
+claim_block(spinlock_t *lock, ext4_grpblk_t block, struct buffer_head *bh)
+{
+       struct journal_head *jh = bh2jh(bh);
+       int ret;
+
+       if (ext4_set_bit_atomic(lock, block, bh->b_data))
+               return 0;
+       jbd_lock_bh_state(bh);
+       if (jh->b_committed_data && ext4_test_bit(block,jh->b_committed_data)) {
+               ext4_clear_bit_atomic(lock, block, bh->b_data);
+               ret = 0;
+       } else {
+               ret = 1;
+       }
+       jbd_unlock_bh_state(bh);
+       return ret;
+}
+
+/**
+ * ext4_try_to_allocate()
+ * @sb:                        superblock
+ * @handle:            handle to this transaction
+ * @group:             given allocation block group
+ * @bitmap_bh:         bufferhead holds the block bitmap
+ * @grp_goal:          given target block within the group
+ * @count:             target number of blocks to allocate
+ * @my_rsv:            reservation window
+ *
+ * Attempt to allocate blocks within a give range. Set the range of allocation
+ * first, then find the first free bit(s) from the bitmap (within the range),
+ * and at last, allocate the blocks by claiming the found free bit as allocated.
+ *
+ * To set the range of this allocation:
+ *     if there is a reservation window, only try to allocate block(s) from the
+ *     file's own reservation window;
+ *     Otherwise, the allocation range starts from the give goal block, ends at
+ *     the block group's last block.
+ *
+ * If we failed to allocate the desired block then we may end up crossing to a
+ * new bitmap.  In that case we must release write access to the old one via
+ * ext4_journal_release_buffer(), else we'll run out of credits.
+ */
+static ext4_grpblk_t
+ext4_try_to_allocate(struct super_block *sb, handle_t *handle, int group,
+                       struct buffer_head *bitmap_bh, ext4_grpblk_t grp_goal,
+                       unsigned long *count, struct ext4_reserve_window *my_rsv)
+{
+       ext4_fsblk_t group_first_block;
+       ext4_grpblk_t start, end;
+       unsigned long num = 0;
+
+       /* we do allocation within the reservation window if we have a window */
+       if (my_rsv) {
+               group_first_block = ext4_group_first_block_no(sb, group);
+               if (my_rsv->_rsv_start >= group_first_block)
+                       start = my_rsv->_rsv_start - group_first_block;
+               else
+                       /* reservation window cross group boundary */
+                       start = 0;
+               end = my_rsv->_rsv_end - group_first_block + 1;
+               if (end > EXT4_BLOCKS_PER_GROUP(sb))
+                       /* reservation window crosses group boundary */
+                       end = EXT4_BLOCKS_PER_GROUP(sb);
+               if ((start <= grp_goal) && (grp_goal < end))
+                       start = grp_goal;
+               else
+                       grp_goal = -1;
+       } else {
+               if (grp_goal > 0)
+                       start = grp_goal;
+               else
+                       start = 0;
+               end = EXT4_BLOCKS_PER_GROUP(sb);
+       }
+
+       BUG_ON(start > EXT4_BLOCKS_PER_GROUP(sb));
+
+repeat:
+       if (grp_goal < 0 || !ext4_test_allocatable(grp_goal, bitmap_bh)) {
+               grp_goal = find_next_usable_block(start, bitmap_bh, end);
+               if (grp_goal < 0)
+                       goto fail_access;
+               if (!my_rsv) {
+                       int i;
+
+                       for (i = 0; i < 7 && grp_goal > start &&
+                                       ext4_test_allocatable(grp_goal - 1,
+                                                               bitmap_bh);
+                                       i++, grp_goal--)
+                               ;
+               }
+       }
+       start = grp_goal;
+
+       if (!claim_block(sb_bgl_lock(EXT4_SB(sb), group),
+               grp_goal, bitmap_bh)) {
+               /*
+                * The block was allocated by another thread, or it was
+                * allocated and then freed by another thread
+                */
+               start++;
+               grp_goal++;
+               if (start >= end)
+                       goto fail_access;
+               goto repeat;
+       }
+       num++;
+       grp_goal++;
+       while (num < *count && grp_goal < end
+               && ext4_test_allocatable(grp_goal, bitmap_bh)
+               && claim_block(sb_bgl_lock(EXT4_SB(sb), group),
+                               grp_goal, bitmap_bh)) {
+               num++;
+               grp_goal++;
+       }
+       *count = num;
+       return grp_goal - num;
+fail_access:
+       *count = num;
+       return -1;
+}
+
+/**
+ *     find_next_reservable_window():
+ *             find a reservable space within the given range.
+ *             It does not allocate the reservation window for now:
+ *             alloc_new_reservation() will do the work later.
+ *
+ *     @search_head: the head of the searching list;
+ *             This is not necessarily the list head of the whole filesystem
+ *
+ *             We have both head and start_block to assist the search
+ *             for the reservable space. The list starts from head,
+ *             but we will shift to the place where start_block is,
+ *             then start from there, when looking for a reservable space.
+ *
+ *     @size: the target new reservation window size
+ *
+ *     @group_first_block: the first block we consider to start
+ *                     the real search from
+ *
+ *     @last_block:
+ *             the maximum block number that our goal reservable space
+ *             could start from. This is normally the last block in this
+ *             group. The search will end when we found the start of next
+ *             possible reservable space is out of this boundary.
+ *             This could handle the cross boundary reservation window
+ *             request.
+ *
+ *     basically we search from the given range, rather than the whole
+ *