## Automatically generated incremental diff
## From:   linux-2.4.17-rc1
## To:     linux-2.4.17-rc2
## Robot:  $Id: make-incremental-diff,v 1.9 2001/12/10 00:06:56 hpa Exp $

diff -urN linux-2.4.17-rc1/Documentation/filesystems/devfs/ChangeLog linux/Documentation/filesystems/devfs/ChangeLog
--- linux-2.4.17-rc1/Documentation/filesystems/devfs/ChangeLog	Tue Dec 18 13:40:12 2001
+++ linux/Documentation/filesystems/devfs/ChangeLog	Tue Dec 18 13:40:15 2001
@@ -1819,3 +1819,29 @@
 Changes for patch v199.3
 
 - Use SLAB_ATOMIC in <devfsd_notify_de> from <devfs_d_delete>
+===============================================================================
+Changes for patch v199.4
+
+- Removed long obsolete rc.devfs
+
+- Return old entry in <devfs_mk_dir> for 2.4.x kernels
+
+- Updated README from master HTML file
+
+- Increment refcount on module in <check_disc_changed>
+
+- Created <devfs_get_handle> and exported <devfs_put>
+
+- Increment refcount on module in <devfs_get_ops>
+
+- Created <devfs_put_ops> and used where needed to fix races
+
+- Added clarifying comments in response to preliminary EMC code review
+===============================================================================
+Changes for patch v199.5
+
+- Added poisoning to <devfs_put>
+
+- Improved debugging messages
+
+- Fixed unregister bugs in drivers/md/lvm-fs.c
diff -urN linux-2.4.17-rc1/Documentation/filesystems/devfs/README linux/Documentation/filesystems/devfs/README
--- linux-2.4.17-rc1/Documentation/filesystems/devfs/README	Tue Dec 18 13:40:12 2001
+++ linux/Documentation/filesystems/devfs/README	Tue Dec 18 13:40:15 2001
@@ -3,7 +3,7 @@
 
 Linux Devfs (Device File System) FAQ
 Richard Gooch
-9-NOV-2001
+13-DEC-2001
 
 -----------------------------------------------------------------------------
 
@@ -66,6 +66,8 @@
 
 Making things work
 Alternatives to devfs
+What I don't like about devfs
+How to report bugs
 
 
 Other resources
@@ -557,8 +559,10 @@
 
 Devfsd
 OK, if you're reading this, I assume you want to play with
-devfs. First you need to compile devfsd, the device management daemon,
-available at 
+devfs. First you should ensure that /usr/src/linux contains a
+recent kernel source tree. Then you need to compile devfsd, the device
+management daemon, available at
+
 http://www.atnf.csiro.au/~rgooch/linux/.
 Because the kernel has a naming scheme
 which is quite different from the old naming scheme, you need to
@@ -1470,6 +1474,7 @@
 Making things work
 Alternatives to devfs
 What I don't like about devfs
+How to report bugs
 
 
 
@@ -1733,6 +1738,57 @@
 
 This is not even remotely true. As shown above,
 both code and data size are quite modest.
+
+
+How to report bugs
+
+If you have (or think you have) a bug with devfs, please follow the
+steps below:
+
+
+
+please make sure you have the latest devfs patches applied. The
+latest kernel version might not have the latest devfs patches applied
+yet (Linus is very busy)
+
+
+save a copy of your complete kernel logs (preferably by
+using the dmesg programme) for later inclusion in your bug
+report. You may need to use the -s switch to increase the
+internal buffer size so you can capture all the boot messages
+
+
+try booting with devfs=dall passed to the kernel boot
+command line (read the documentation on your bootloader on how to do
+this), and save the result to a file. This may be quite verbose, and
+it may overflow the messages buffer, but try to get as much of it as
+you can
+
+
+if you get an Oops, run ksymoops to decode it so that the
+names of the offending functions are provided. A non-decoded Oops is
+pretty useless
+
+
+send a copy of your devfsd configuration file(s)
+
+send the bug report to me first.
+Don't expect that I will see it if you post it to the linux-kernel
+mailing list. Include all the information listed above, plus
+anything else that you think might be relevant. Put the string
+devfs somewhere in the subject line, so my mail filters mark
+it as urgent
+
+
+
+
+Here is a general guide on how to ask questions in a way that greatly
+improves your chances of getting a reply:
+
+http://www.tuxedo.org/~esr/faqs/smart-questions.html. If you have
+a bug to report, you should also read
+
+http://www.chiark.greenend.org.uk/~sgtatham/bugs.html.
 
 -----------------------------------------------------------------------------
 
diff -urN linux-2.4.17-rc1/Documentation/filesystems/devfs/rc.devfs linux/Documentation/filesystems/devfs/rc.devfs
--- linux-2.4.17-rc1/Documentation/filesystems/devfs/rc.devfs	Wed Feb 16 15:42:05 2000
+++ linux/Documentation/filesystems/devfs/rc.devfs	Wed Dec 31 16:00:00 1969
@@ -1,104 +0,0 @@
-#! /bin/sh
-#
-#  /etc/rc.d/rc.devfs
-#
-#  Linux Boot Scripts by  Richard Gooch <rgooch@atnf.csiro.au>
-#  Copyright 1993-1999 under GNU Copyleft version 2.0. See /etc/rc for
-#  copyright notice.
-#
-#  Save and restore devfs ownerships and permissions
-#
-#	Written by	Richard Gooch   11-JAN-1998
-#
-#	Updated by	Richard Gooch	23-JAN-1998: Added "start" and "stop".
-#
-#	Updated by	Richard Gooch	5-AUG-1998: Robustness improvements by
-# Roderich Schupp.
-#
-#	Updated by	Richard Gooch	9-AUG-1998: Took account of change from
-# ".epoch" to ".devfsd".
-#
-#	Updated by	Richard Gooch	19-AUG-1998: Test and tty pattern patch
-# by Roderich Schupp.
-#
-#	Updated by	Richard Gooch	24-MAY-1999: Use sed instead of tr.
-#
-#	Last updated by	Richard Gooch	25-MAY-1999: Don't save /dev/log.
-#
-#
-# Usage:  rc.devfs save|restore [savedir] [devfsdir]
-#
-# Note: "start" is a synonym for "restore" and "stop" is a synonym for "save".
-
-# Set VERBOSE to "no" if you would like a more quiet operation.
-VERBOSE=yes
-
-# Set TAROPTS to "v" or even "vv" to see which files get saved/restored.
-TAROPTS=
-
-option="$1"
-
-case "$option" in
-    save|restore) ;;
-    start)  option=restore ;;
-    stop)   option=save ;;
-    *)      echo "No save or restore option given" ; exit 1 ;;
-esac
-
-if [ "$2" = "" ]; then
-    savedir=/var/state
-else
-    savedir=$2
-fi
-
-if [ ! -d $savedir ]; then
-    echo "Directory: $savedir does not exist"
-    exit 1
-fi
-
-if [ "$3" = "" ]; then
-    if [ -d /devfs ]; then
-	devfs=/devfs
-    else
-	devfs=/dev
-    fi
-else
-    devfs=$3
-fi
-
-grep devfs /proc/filesystems >/dev/null || exit 0
-
-if [ ! -d $devfs ]; then
-    echo "Directory: $devfs does not exist"
-    exit 1
-elif [ ! -c $devfs/.devfsd ]; then
-    echo "Directory: $devfs is not the root of a devfs filesystem"
-    exit 1
-fi
-
-savefile=`echo $devfs | sed 's*/*_*g'`
-tarfile=${savedir}/devfssave.${savefile}.tar.gz
-
-cd $devfs
-
-case "$option" in
-    save)
-	[ "$VERBOSE" != no ] && echo "Saving $devfs permissions..."
-	
-	# You might want to adjust the pattern below to control
-	# which file's permissions will be saved.
-	# The sample pattern exludes all virtual consoles
-	# as well as old and new style pseudo terminals.
-	files=`find * -noleaf -cnewer .devfsd \
-	       ! -regex 'tty[0-9]+\|vc/.*\|vcsa?[0-9]+\|vcc/.*\|[pt]ty[a-z][0-9a-f]\|pt[ms]/.*\|log' -print`
-	rm -f $tarfile
-	[ -n "$files" ] && tar cz${TAROPTS}f $tarfile $files
-	;;
-
-    restore)
-	[ "$VERBOSE" != no ] && echo "Restoring $devfs permissions..."
-	[ -f $tarfile ] && tar xpz${TAROPTS}f $tarfile
-	;;
-esac
-
-exit 0
diff -urN linux-2.4.17-rc1/Documentation/filesystems/ntfs.txt linux/Documentation/filesystems/ntfs.txt
--- linux-2.4.17-rc1/Documentation/filesystems/ntfs.txt	Sun Sep 30 11:42:44 2001
+++ linux/Documentation/filesystems/ntfs.txt	Tue Dec 18 13:40:15 2001
@@ -98,6 +98,16 @@
 ChangeLog
 =========
 
+NTFS 1.1.21:
+	- Fixed bug with reading $MFT where we try to read higher mft records
+	  before having read the $DATA attribute of $MFT. (Note this is only a
+	  partial solution which will only work in the case that the attribute
+	  list is resident or non-resident but $DATA is in the first 1024
+	  bytes. But this should be enough in the majority of cases. I am not
+	  going to bother fixing the general case until someone finds this to
+	  be a problem for them, which I doubt very much will ever happen...)
+	- Fixed bogus BUG() call in readdir().
+
 NTFS 1.1.20:
 	- Fixed two bugs in ntfs_readwrite_attr(). Thanks to Jan Kara for
 	  spotting the out of bounds one.
diff -urN linux-2.4.17-rc1/Makefile linux/Makefile
--- linux-2.4.17-rc1/Makefile	Tue Dec 18 13:40:13 2001
+++ linux/Makefile	Tue Dec 18 13:40:15 2001
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 4
 SUBLEVEL = 17
-EXTRAVERSION = -rc1
+EXTRAVERSION = -rc2
 
 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 
diff -urN linux-2.4.17-rc1/arch/alpha/kernel/irq_i8259.c linux/arch/alpha/kernel/irq_i8259.c
--- linux-2.4.17-rc1/arch/alpha/kernel/irq_i8259.c	Mon Jun 19 17:59:32 2000
+++ linux/arch/alpha/kernel/irq_i8259.c	Tue Dec 18 13:40:15 2001
@@ -22,7 +22,7 @@
 
 /* Note mask bit is true for DISABLED irqs.  */
 static unsigned int cached_irq_mask = 0xffff;
-spinlock_t i8259_irq_lock = SPIN_LOCK_UNLOCKED;
+static spinlock_t i8259_irq_lock = SPIN_LOCK_UNLOCKED;
 
 static inline void
 i8259_update_irq_hw(unsigned int irq, unsigned long mask)
diff -urN linux-2.4.17-rc1/arch/i386/kernel/pci-pc.c linux/arch/i386/kernel/pci-pc.c
--- linux-2.4.17-rc1/arch/i386/kernel/pci-pc.c	Fri Nov  9 13:58:02 2001
+++ linux/arch/i386/kernel/pci-pc.c	Tue Dec 18 13:40:15 2001
@@ -30,7 +30,7 @@
  * This interrupt-safe spinlock protects all accesses to PCI
  * configuration space.
  */
-spinlock_t pci_config_lock = SPIN_LOCK_UNLOCKED;
+static spinlock_t pci_config_lock = SPIN_LOCK_UNLOCKED;
 
 
 /*
diff -urN linux-2.4.17-rc1/arch/ia64/kernel/efivars.c linux/arch/ia64/kernel/efivars.c
--- linux-2.4.17-rc1/arch/ia64/kernel/efivars.c	Fri Nov  9 14:26:17 2001
+++ linux/arch/ia64/kernel/efivars.c	Tue Dec 18 13:40:16 2001
@@ -100,7 +100,7 @@
 	struct list_head        list;
 } efivar_entry_t;
 
-spinlock_t efivars_lock = SPIN_LOCK_UNLOCKED;
+static spinlock_t efivars_lock = SPIN_LOCK_UNLOCKED;
 static LIST_HEAD(efivar_list);
 static struct proc_dir_entry *efi_vars_dir = NULL;
 
diff -urN linux-2.4.17-rc1/arch/ia64/kernel/pci.c linux/arch/ia64/kernel/pci.c
--- linux-2.4.17-rc1/arch/ia64/kernel/pci.c	Fri Nov  9 14:26:17 2001
+++ linux/arch/ia64/kernel/pci.c	Tue Dec 18 13:40:16 2001
@@ -46,7 +46,7 @@
  * This interrupt-safe spinlock protects all accesses to PCI
  * configuration space.
  */
-spinlock_t pci_lock = SPIN_LOCK_UNLOCKED;
+static spinlock_t pci_lock = SPIN_LOCK_UNLOCKED;
 
 struct pci_fixup pcibios_fixups[] = {
 	{ 0 }
diff -urN linux-2.4.17-rc1/arch/ia64/sn/io/hcl.c linux/arch/ia64/sn/io/hcl.c
--- linux-2.4.17-rc1/arch/ia64/sn/io/hcl.c	Thu Apr  5 12:51:47 2001
+++ linux/arch/ia64/sn/io/hcl.c	Tue Dec 18 13:40:16 2001
@@ -1049,16 +1049,22 @@
 struct file_operations *
 hwgraph_cdevsw_get(devfs_handle_t de)
 {
-	return(devfs_get_ops(de));
+	struct file_operations *fops = devfs_get_ops(de);
+
+	devfs_put_ops(de); /*  FIXME: this may need to be moved to callers  */
+	return(fops);
 }
 
 /*
  * hwgraph_bdevsw_get - returns the fops of the given devfs entry.
 */
-struct file_operations *
+struct file_operations *    /*  FIXME: shouldn't this be a blkdev?  */
 hwgraph_bdevsw_get(devfs_handle_t de)
 {
-	return(devfs_get_ops(de));
+	struct file_operations *fops = devfs_get_ops(de);
+
+	devfs_put_ops(de); /*  FIXME: this may need to be moved to callers  */
+	return(fops);
 }
 
 /*
diff -urN linux-2.4.17-rc1/arch/ia64/sn/io/hubspc.c linux/arch/ia64/sn/io/hubspc.c
--- linux-2.4.17-rc1/arch/ia64/sn/io/hubspc.c	Thu Apr  5 12:51:47 2001
+++ linux/arch/ia64/sn/io/hubspc.c	Tue Dec 18 13:40:16 2001
@@ -61,7 +61,7 @@
 }cpuprom_info_t;
 
 static cpuprom_info_t	*cpuprom_head;
-spinlock_t	cpuprom_spinlock;
+static spinlock_t	cpuprom_spinlock;
 #define	PROM_LOCK()	mutex_spinlock(&cpuprom_spinlock)
 #define	PROM_UNLOCK(s)	mutex_spinunlock(&cpuprom_spinlock, (s))
 
diff -urN linux-2.4.17-rc1/arch/ppc/kernel/i8259.c linux/arch/ppc/kernel/i8259.c
--- linux-2.4.17-rc1/arch/ppc/kernel/i8259.c	Mon May 21 17:04:47 2001
+++ linux/arch/ppc/kernel/i8259.c	Tue Dec 18 13:40:16 2001
@@ -13,7 +13,7 @@
 #define cached_A1 (cached_8259[0])
 #define cached_21 (cached_8259[1])
 
-spinlock_t i8259_lock = SPIN_LOCK_UNLOCKED;
+static spinlock_t i8259_lock = SPIN_LOCK_UNLOCKED;
 
 int i8259_pic_irq_offset;
 
diff -urN linux-2.4.17-rc1/arch/ppc/kernel/pmac_pic.c linux/arch/ppc/kernel/pmac_pic.c
--- linux-2.4.17-rc1/arch/ppc/kernel/pmac_pic.c	Sat Sep  8 12:38:42 2001
+++ linux/arch/ppc/kernel/pmac_pic.c	Tue Dec 18 13:40:16 2001
@@ -36,7 +36,7 @@
 static int max_irqs;
 static int max_real_irqs;
 
-spinlock_t pmac_pic_lock = SPIN_LOCK_UNLOCKED;
+static spinlock_t pmac_pic_lock = SPIN_LOCK_UNLOCKED;
 
 
 #define GATWICK_IRQ_POOL_SIZE        10
diff -urN linux-2.4.17-rc1/arch/ppc/kernel/prom.c linux/arch/ppc/kernel/prom.c
--- linux-2.4.17-rc1/arch/ppc/kernel/prom.c	Sat Sep  8 12:38:42 2001
+++ linux/arch/ppc/kernel/prom.c	Tue Dec 18 13:40:16 2001
@@ -1928,7 +1928,7 @@
 }
 #endif
 
-spinlock_t rtas_lock = SPIN_LOCK_UNLOCKED;
+static spinlock_t rtas_lock = SPIN_LOCK_UNLOCKED;
 
 /* this can be called after setup -- Cort */
 int __openfirmware
diff -urN linux-2.4.17-rc1/arch/sparc64/solaris/timod.c linux/arch/sparc64/solaris/timod.c
--- linux-2.4.17-rc1/arch/sparc64/solaris/timod.c	Thu Sep 20 14:11:57 2001
+++ linux/arch/sparc64/solaris/timod.c	Tue Dec 18 13:40:17 2001
@@ -33,7 +33,7 @@
 	u32 arg);
 asmlinkage int solaris_ioctl(unsigned int fd, unsigned int cmd, u32 arg);
 
-spinlock_t timod_pagelock = SPIN_LOCK_UNLOCKED;
+static spinlock_t timod_pagelock = SPIN_LOCK_UNLOCKED;
 static char * page = NULL ;
 
 #ifndef DEBUG_SOLARIS_KMALLOC
diff -urN linux-2.4.17-rc1/drivers/acpi/ospm/ac_adapter/ac_osl.c linux/drivers/acpi/ospm/ac_adapter/ac_osl.c
--- linux-2.4.17-rc1/drivers/acpi/ospm/ac_adapter/ac_osl.c	Wed Oct 24 14:06:22 2001
+++ linux/drivers/acpi/ospm/ac_adapter/ac_osl.c	Tue Dec 18 13:40:17 2001
@@ -35,6 +35,7 @@
 
 MODULE_AUTHOR("Andrew Grover");
 MODULE_DESCRIPTION("ACPI Component Architecture (CA) - AC Adapter Driver");
+MODULE_LICENSE("GPL");
 
 
 #define AC_PROC_ROOT		"ac_adapter"
diff -urN linux-2.4.17-rc1/drivers/acpi/ospm/battery/bt_osl.c linux/drivers/acpi/ospm/battery/bt_osl.c
--- linux-2.4.17-rc1/drivers/acpi/ospm/battery/bt_osl.c	Wed Oct 24 14:06:22 2001
+++ linux/drivers/acpi/ospm/battery/bt_osl.c	Tue Dec 18 13:40:17 2001
@@ -44,6 +44,7 @@
 
 MODULE_AUTHOR("Andrew Grover");
 MODULE_DESCRIPTION("ACPI Component Architecture (CA) - Control Method Battery Driver");
+MODULE_LICENSE("GPL");
 
 
 #define BT_PROC_ROOT		"battery"
diff -urN linux-2.4.17-rc1/drivers/acpi/ospm/busmgr/bm_osl.c linux/drivers/acpi/ospm/busmgr/bm_osl.c
--- linux-2.4.17-rc1/drivers/acpi/ospm/busmgr/bm_osl.c	Wed Oct 24 14:06:22 2001
+++ linux/drivers/acpi/ospm/busmgr/bm_osl.c	Tue Dec 18 13:40:17 2001
@@ -38,6 +38,7 @@
 
 MODULE_AUTHOR("Andrew Grover");
 MODULE_DESCRIPTION("ACPI Component Architecture (CA) - ACPI Bus Manager");
+MODULE_LICENSE("GPL");
 
 
 /*****************************************************************************
diff -urN linux-2.4.17-rc1/drivers/acpi/ospm/button/bn_osl.c linux/drivers/acpi/ospm/button/bn_osl.c
--- linux-2.4.17-rc1/drivers/acpi/ospm/button/bn_osl.c	Wed Oct 24 14:06:22 2001
+++ linux/drivers/acpi/ospm/button/bn_osl.c	Tue Dec 18 13:40:17 2001
@@ -35,6 +35,7 @@
 
 MODULE_AUTHOR("Andrew Grover");
 MODULE_DESCRIPTION("ACPI Component Architecture (CA) - Button Driver");
+MODULE_LICENSE("GPL");
 
 
 #define BN_PROC_ROOT		"button"
diff -urN linux-2.4.17-rc1/drivers/acpi/ospm/ec/ec_osl.c linux/drivers/acpi/ospm/ec/ec_osl.c
--- linux-2.4.17-rc1/drivers/acpi/ospm/ec/ec_osl.c	Wed Oct 24 14:06:22 2001
+++ linux/drivers/acpi/ospm/ec/ec_osl.c	Tue Dec 18 13:40:17 2001
@@ -36,6 +36,7 @@
 
 MODULE_AUTHOR("Andrew Grover");
 MODULE_DESCRIPTION("ACPI Component Architecture (CA) - Embedded Controller Driver");
+MODULE_LICENSE("GPL");
 
 extern struct proc_dir_entry	*bm_proc_root;
 
diff -urN linux-2.4.17-rc1/drivers/acpi/ospm/processor/pr_osl.c linux/drivers/acpi/ospm/processor/pr_osl.c
--- linux-2.4.17-rc1/drivers/acpi/ospm/processor/pr_osl.c	Fri Nov  9 13:58:02 2001
+++ linux/drivers/acpi/ospm/processor/pr_osl.c	Tue Dec 18 13:40:17 2001
@@ -37,6 +37,7 @@
 
 MODULE_AUTHOR("Andrew Grover");
 MODULE_DESCRIPTION("ACPI Component Architecture (CA) - IA32 Processor Driver");
+MODULE_LICENSE("GPL");
 
 
 #define PR_PROC_ROOT		"processor"
diff -urN linux-2.4.17-rc1/drivers/acpi/ospm/system/sm_osl.c linux/drivers/acpi/ospm/system/sm_osl.c
--- linux-2.4.17-rc1/drivers/acpi/ospm/system/sm_osl.c	Wed Oct 24 14:06:22 2001
+++ linux/drivers/acpi/ospm/system/sm_osl.c	Tue Dec 18 13:40:17 2001
@@ -42,6 +42,7 @@
 
 MODULE_AUTHOR("Andrew Grover");
 MODULE_DESCRIPTION("ACPI Component Architecture (CA) - ACPI System Driver");
+MODULE_LICENSE("GPL");
 
 
 #define SM_PROC_INFO		"info"
diff -urN linux-2.4.17-rc1/drivers/acpi/ospm/thermal/tz_osl.c linux/drivers/acpi/ospm/thermal/tz_osl.c
--- linux-2.4.17-rc1/drivers/acpi/ospm/thermal/tz_osl.c	Wed Oct 24 14:06:22 2001
+++ linux/drivers/acpi/ospm/thermal/tz_osl.c	Tue Dec 18 13:40:17 2001
@@ -35,6 +35,7 @@
 
 MODULE_AUTHOR("Andrew Grover");
 MODULE_DESCRIPTION("ACPI Component Architecture (CA) - Thermal Zone Driver");
+MODULE_LICENSE("GPL");
 
 int TZP = 0;
 MODULE_PARM(TZP, "i");
diff -urN linux-2.4.17-rc1/drivers/block/loop.c linux/drivers/block/loop.c
--- linux-2.4.17-rc1/drivers/block/loop.c	Tue Dec 18 13:40:13 2001
+++ linux/drivers/block/loop.c	Tue Dec 18 13:40:17 2001
@@ -578,6 +578,8 @@
 	atomic_inc(&lo->lo_pending);
 	spin_unlock_irq(&lo->lo_lock);
 
+	current->flags |= PF_NOIO;
+
 	/*
 	 * up sem, we are running
 	 */
diff -urN linux-2.4.17-rc1/drivers/char/agp/agpgart_be.c linux/drivers/char/agp/agpgart_be.c
--- linux-2.4.17-rc1/drivers/char/agp/agpgart_be.c	Tue Dec 18 13:40:13 2001
+++ linux/drivers/char/agp/agpgart_be.c	Tue Dec 18 13:40:17 2001
@@ -3897,12 +3897,10 @@
 
 		case PCI_DEVICE_ID_INTEL_830_M_0:
 			i810_dev = pci_find_device(PCI_VENDOR_ID_INTEL,
-									   PCI_DEVICE_ID_INTEL_830_M_1,
-									   NULL);
-			if(PCI_FUNC(i810_dev->devfn) != 0) {
+					PCI_DEVICE_ID_INTEL_830_M_1, NULL);
+			if(i810_dev && PCI_FUNC(i810_dev->devfn) != 0) {
 				i810_dev = pci_find_device(PCI_VENDOR_ID_INTEL,
-										   PCI_DEVICE_ID_INTEL_830_M_1,
-										   i810_dev);
+					PCI_DEVICE_ID_INTEL_830_M_1, i810_dev);
 			}
 
 			if (i810_dev == NULL) {
diff -urN linux-2.4.17-rc1/drivers/char/synclink.c linux/drivers/char/synclink.c
--- linux-2.4.17-rc1/drivers/char/synclink.c	Fri Sep 14 14:39:59 2001
+++ linux/drivers/char/synclink.c	Tue Dec 18 13:40:17 2001
@@ -926,7 +926,7 @@
 
 static int __init synclink_init_one (struct pci_dev *dev,
 				     const struct pci_device_id *ent);
-static void __exit synclink_remove_one (struct pci_dev *dev);
+static void __devexit synclink_remove_one (struct pci_dev *dev);
 
 static struct pci_device_id synclink_pci_tbl[] __devinitdata = {
 	{ PCI_VENDOR_ID_MICROGATE, PCI_DEVICE_ID_MICROGATE_USC, PCI_ANY_ID, PCI_ANY_ID, },
diff -urN linux-2.4.17-rc1/drivers/char/sysrq.c linux/drivers/char/sysrq.c
--- linux-2.4.17-rc1/drivers/char/sysrq.c	Tue Oct  2 09:20:37 2001
+++ linux/drivers/char/sysrq.c	Tue Dec 18 13:40:17 2001
@@ -336,7 +336,7 @@
 
 
 /* Key Operations table and lock */
-spinlock_t sysrq_key_table_lock = SPIN_LOCK_UNLOCKED;
+static spinlock_t sysrq_key_table_lock = SPIN_LOCK_UNLOCKED;
 #define SYSRQ_KEY_TABLE_LENGTH 36
 static struct sysrq_key_op *sysrq_key_table[SYSRQ_KEY_TABLE_LENGTH] = {
 /* 0 */	&sysrq_loglevel_op,
diff -urN linux-2.4.17-rc1/drivers/md/lvm-fs.c linux/drivers/md/lvm-fs.c
--- linux-2.4.17-rc1/drivers/md/lvm-fs.c	Sun Nov 11 10:09:32 2001
+++ linux/drivers/md/lvm-fs.c	Tue Dec 18 13:40:17 2001
@@ -30,6 +30,7 @@
  *    04/10/2001 - corrected devfs_register() call in lvm_init_fs()
  *    11/04/2001 - don't devfs_register("lvm") as user-space always does it
  *    10/05/2001 - show more of PV name in /proc/lvm/global
+ *    16/12/2001 - fix devfs unregister order and prevent duplicate unreg (REG)
  *
  */
 
@@ -138,7 +139,7 @@
 	int i;
 
 	devfs_unregister(ch_devfs_handle[vg_ptr->vg_number]);
-	devfs_unregister(vg_devfs_handle[vg_ptr->vg_number]);
+	ch_devfs_handle[vg_ptr->vg_number] = NULL;
 
 	/* remove lv's */
 	for(i = 0; i < vg_ptr->lv_max; i++)
@@ -148,6 +149,10 @@
 	for(i = 0; i < vg_ptr->pv_max; i++)
 		if(vg_ptr->pv[i]) lvm_fs_remove_pv(vg_ptr, vg_ptr->pv[i]);
 
+	/* must not remove directory before leaf nodes */
+	devfs_unregister(vg_devfs_handle[vg_ptr->vg_number]);
+	vg_devfs_handle[vg_ptr->vg_number] = NULL;
+
 	if(vg_ptr->vg_dir_pde) {
 		remove_proc_entry(LVM_LV_SUBDIR, vg_ptr->vg_dir_pde);
 		vg_ptr->lv_subdir_pde = NULL;
@@ -189,6 +194,7 @@
 
 void lvm_fs_remove_lv(vg_t *vg_ptr, lv_t *lv) {
 	devfs_unregister(lv_devfs_handle[MINOR(lv->lv_dev)]);
+	lv_devfs_handle[MINOR(lv->lv_dev)] = NULL;
 
 	if(vg_ptr->lv_subdir_pde) {
 		const char *name = _basename(lv->lv_name);
diff -urN linux-2.4.17-rc1/drivers/md/md.c linux/drivers/md/md.c
--- linux-2.4.17-rc1/drivers/md/md.c	Mon Nov 26 05:29:17 2001
+++ linux/drivers/md/md.c	Tue Dec 18 13:40:17 2001
@@ -4039,4 +4039,4 @@
 MD_EXPORT_SYMBOL(mddev_map);
 MD_EXPORT_SYMBOL(md_check_ordering);
 MD_EXPORT_SYMBOL(get_spare);
-
+MODULE_LICENSE("GPL");
diff -urN linux-2.4.17-rc1/drivers/net/dmfe.c linux/drivers/net/dmfe.c
--- linux-2.4.17-rc1/drivers/net/dmfe.c	Fri Nov  9 13:50:01 2001
+++ linux/drivers/net/dmfe.c	Tue Dec 18 13:40:17 2001
@@ -527,7 +527,7 @@
 }
 
 
-static void __exit dmfe_remove_one (struct pci_dev *pdev)
+static void __devexit dmfe_remove_one (struct pci_dev *pdev)
 {
 	struct net_device *dev = pci_get_drvdata(pdev);
 	struct dmfe_board_info *db = dev->priv;
@@ -2059,7 +2059,7 @@
 	name:		"dmfe",
 	id_table:	dmfe_pci_tbl,
 	probe:		dmfe_init_one,
-	remove:		dmfe_remove_one,
+	remove:		__devexit_p(dmfe_remove_one),
 };
 
 MODULE_AUTHOR("Sten Wang, sten_wang@davicom.com.tw");
diff -urN linux-2.4.17-rc1/drivers/net/hamachi.c linux/drivers/net/hamachi.c
--- linux-2.4.17-rc1/drivers/net/hamachi.c	Tue Oct  9 15:13:03 2001
+++ linux/drivers/net/hamachi.c	Tue Dec 18 13:40:17 2001
@@ -1981,7 +1981,7 @@
 }
 
 
-static void __exit hamachi_remove_one (struct pci_dev *pdev)
+static void __devexit hamachi_remove_one (struct pci_dev *pdev)
 {
 	struct net_device *dev = pci_get_drvdata(pdev);
 
@@ -2011,7 +2011,7 @@
 	name:		DRV_NAME,
 	id_table:	hamachi_pci_tbl,
 	probe:		hamachi_init_one,
-	remove:		hamachi_remove_one,
+	remove:		__devexit_p(hamachi_remove_one),
 };
 
 static int __init hamachi_init (void)
diff -urN linux-2.4.17-rc1/drivers/net/pcmcia/fmvj18x_cs.c linux/drivers/net/pcmcia/fmvj18x_cs.c
--- linux-2.4.17-rc1/drivers/net/pcmcia/fmvj18x_cs.c	Tue Nov 13 09:02:30 2001
+++ linux/drivers/net/pcmcia/fmvj18x_cs.c	Tue Dec 18 13:40:17 2001
@@ -1247,3 +1247,4 @@
     }
     restore_flags(flags);
 }
+MODULE_LICENSE("GPL");
diff -urN linux-2.4.17-rc1/drivers/net/tokenring/abyss.c linux/drivers/net/tokenring/abyss.c
--- linux-2.4.17-rc1/drivers/net/tokenring/abyss.c	Thu Sep 13 16:04:43 2001
+++ linux/drivers/net/tokenring/abyss.c	Tue Dec 18 13:40:17 2001
@@ -433,7 +433,7 @@
 	return 0;
 }
 
-static void __exit abyss_detach (struct pci_dev *pdev)
+static void __devexit abyss_detach (struct pci_dev *pdev)
 {
 	struct net_device *dev = pci_get_drvdata(pdev);
 	
@@ -451,7 +451,7 @@
 	name:		"abyss",
 	id_table:	abyss_pci_tbl,
 	probe:		abyss_attach,
-	remove:		abyss_detach,
+	remove:		__devexit_p(abyss_detach),
 };
 
 static int __init abyss_init (void)
diff -urN linux-2.4.17-rc1/drivers/net/tokenring/tmspci.c linux/drivers/net/tokenring/tmspci.c
--- linux-2.4.17-rc1/drivers/net/tokenring/tmspci.c	Thu Sep 13 16:04:43 2001
+++ linux/drivers/net/tokenring/tmspci.c	Tue Dec 18 13:40:17 2001
@@ -220,7 +220,7 @@
 	return val;
 }
 
-static void __exit tms_pci_detach (struct pci_dev *pdev)
+static void __devexit tms_pci_detach (struct pci_dev *pdev)
 {
 	struct net_device *dev = pci_get_drvdata(pdev);
 
@@ -238,7 +238,7 @@
 	name:		"tmspci",
 	id_table:	tmspci_pci_tbl,
 	probe:		tms_pci_attach,
-	remove:		tms_pci_detach,
+	remove:		__devexit_p(tms_pci_detach),
 };
 
 static int __init tms_pci_init (void)
diff -urN linux-2.4.17-rc1/drivers/net/via-rhine.c linux/drivers/net/via-rhine.c
--- linux-2.4.17-rc1/drivers/net/via-rhine.c	Tue Dec 18 13:40:13 2001
+++ linux/drivers/net/via-rhine.c	Tue Dec 18 13:40:17 2001
@@ -161,7 +161,7 @@
 KERN_INFO "via-rhine.c:v1.10-LK1.1.12  03/11/2001  Written by Donald Becker\n"
 KERN_INFO "  http://www.scyld.com/network/via-rhine.html\n";
 
-static char shortname[] __devinitdata = "via-rhine";
+static char shortname[] = "via-rhine";
 
 
 /* This driver was written to use PCI memory space, however most versions
diff -urN linux-2.4.17-rc1/drivers/net/wan/dscc4.c linux/drivers/net/wan/dscc4.c
--- linux-2.4.17-rc1/drivers/net/wan/dscc4.c	Fri Nov  9 13:41:42 2001
+++ linux/drivers/net/wan/dscc4.c	Tue Dec 18 13:40:17 2001
@@ -1634,7 +1634,7 @@
 	return &priv->stats;
 }
 
-static void __exit dscc4_remove_one(struct pci_dev *pdev)
+static void __devexit dscc4_remove_one(struct pci_dev *pdev)
 {
 	struct dscc4_pci_priv *ppriv;
 	struct net_device *root;
@@ -1752,7 +1752,7 @@
 	name:           "dscc4",
 	id_table:       dscc4_pci_tbl,
 	probe:          dscc4_init_one,
-	remove:         dscc4_remove_one,
+	remove:         __devexit_p(dscc4_remove_one),
 };
 
 static int __init dscc4_init_module(void)
diff -urN linux-2.4.17-rc1/drivers/scsi/g_NCR5380.c linux/drivers/scsi/g_NCR5380.c
--- linux-2.4.17-rc1/drivers/scsi/g_NCR5380.c	Tue Dec 18 13:40:13 2001
+++ linux/drivers/scsi/g_NCR5380.c	Tue Dec 18 13:40:17 2001
@@ -911,41 +911,7 @@
 MODULE_DEVICE_TABLE(isapnp, id_table);
 
 
-#ifndef MODULE
-
-static int __init do_NCR53C400_setup(char *str)
-{
-	int ints[10];
-
-	get_options(str, sizeof(ints) / sizeof(int), ints);
-	generic_NCR53C400_setup(str, ints);
-
-	return 1;
-}
-
-static int __init do_NCR53C400A_setup(char *str)
-{
-	int ints[10];
-
-	get_options(str, sizeof(ints) / sizeof(int), ints);
-	generic_NCR53C400A_setup(str, ints);
-
-	return 1;
-}
-
-static int __init do_DTC3181E_setup(char *str)
-{
-	int ints[10];
-
-	get_options(str, sizeof(ints) / sizeof(int), ints);
-	generic_DTC3181E_setup(str, ints);
-
-	return 1;
-}
-
 __setup("ncr5380=", do_NCR5380_setup);
 __setup("ncr53c400=", do_NCR53C400_setup);
 __setup("ncr53c400a=", do_NCR53C400A_setup);
 __setup("dtc3181e=", do_DTC3181E_setup);
-
-#endif
diff -urN linux-2.4.17-rc1/drivers/video/aty/atyfb_base.c linux/drivers/video/aty/atyfb_base.c
--- linux-2.4.17-rc1/drivers/video/aty/atyfb_base.c	Tue Dec 18 13:40:13 2001
+++ linux/drivers/video/aty/atyfb_base.c	Tue Dec 18 13:40:18 2001
@@ -2927,3 +2927,4 @@
 }
 
 #endif
+MODULE_LICENSE("GPL");
diff -urN linux-2.4.17-rc1/drivers/video/fbmem.c linux/drivers/video/fbmem.c
--- linux-2.4.17-rc1/drivers/video/fbmem.c	Wed Nov 14 15:41:37 2001
+++ linux/drivers/video/fbmem.c	Tue Dec 18 13:40:18 2001
@@ -931,3 +931,5 @@
 #if 1 /* to go away in 2.5.0 */
 EXPORT_SYMBOL(GET_FB_IDX);
 #endif
+
+MODULE_LICENSE("GPL");
diff -urN linux-2.4.17-rc1/fs/block_dev.c linux/fs/block_dev.c
--- linux-2.4.17-rc1/fs/block_dev.c	Tue Dec 18 13:40:13 2001
+++ linux/fs/block_dev.c	Tue Dec 18 13:40:18 2001
@@ -499,7 +499,10 @@
 
 		de = devfs_find_handle (NULL, NULL, i, MINOR (dev),
 					DEVFS_SPECIAL_BLK, 0);
-		if (de) bdops = devfs_get_ops (de);
+		if (de) {
+			bdops = devfs_get_ops (de);
+			devfs_put_ops (de); /* We're running in owner module */
+		}
 	}
 	if (bdops == NULL)
 		return 0;
diff -urN linux-2.4.17-rc1/fs/buffer.c linux/fs/buffer.c
--- linux-2.4.17-rc1/fs/buffer.c	Tue Dec 18 13:40:13 2001
+++ linux/fs/buffer.c	Tue Dec 18 13:40:18 2001
@@ -1045,7 +1045,7 @@
 
 	/* First, check for the "real" dirty limit. */
 	if (dirty > soft_dirty_limit) {
-		if (dirty > hard_dirty_limit)
+		if (dirty > hard_dirty_limit && !(current->flags & PF_NOIO))
 			return 1;
 		return 0;
 	}
diff -urN linux-2.4.17-rc1/fs/devfs/base.c linux/fs/devfs/base.c
--- linux-2.4.17-rc1/fs/devfs/base.c	Tue Dec 18 13:40:13 2001
+++ linux/fs/devfs/base.c	Tue Dec 18 13:40:18 2001
@@ -579,6 +579,19 @@
     20011204   Richard Gooch <rgooch@atnf.csiro.au>
 	       Use SLAB_ATOMIC in <devfsd_notify_de> from <devfs_d_delete>.
   v1.5
+    20011211   Richard Gooch <rgooch@atnf.csiro.au>
+	       Return old entry in <devfs_mk_dir> for 2.4.x kernels.
+    20011212   Richard Gooch <rgooch@atnf.csiro.au>
+	       Increment refcount on module in <check_disc_changed>.
+    20011215   Richard Gooch <rgooch@atnf.csiro.au>
+	       Created <devfs_get_handle> and exported <devfs_put>.
+	       Increment refcount on module in <devfs_get_ops>.
+	       Created <devfs_put_ops>.
+  v1.6
+    20011216   Richard Gooch <rgooch@atnf.csiro.au>
+	       Added poisoning to <devfs_put>.
+	       Improved debugging messages.
+  v1.7
 */
 #include <linux/types.h>
 #include <linux/errno.h>
@@ -611,13 +624,15 @@
 #include <asm/bitops.h>
 #include <asm/atomic.h>
 
-#define DEVFS_VERSION            "1.5 (20011204)"
+#define DEVFS_VERSION            "1.7 (20011216)"
 
 #define DEVFS_NAME "devfs"
 
 #define FIRST_INODE 1
 
 #define STRING_LENGTH 256
+#define FAKE_BLOCK_SIZE 1024
+#define POISON_PTR ( *(void **) poison_array )
 
 #ifndef TRUE
 #  define TRUE 1
@@ -775,6 +790,8 @@
 static unsigned int stat_num_entries;
 static unsigned int stat_num_bytes;
 #endif
+static unsigned char poison_array[8] =
+    {0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a};
 
 #ifdef CONFIG_DEVFS_MOUNT
 static unsigned int boot_options = OPTION_MOUNT;
@@ -826,12 +843,14 @@
 
 /**
  *	devfs_put - Put (release) a reference to a devfs entry.
- *	@de:  The devfs entry.
+ *	@de:  The handle to the devfs entry.
  */
 
-static void devfs_put (struct devfs_entry *de)
+void devfs_put (devfs_handle_t de)
 {
     if (!de) return;
+    if (de->info == POISON_PTR)
+	OOPS ("%s: devfs_put(%p): poisoned pointer\n", DEVFS_NAME, de);
     if ( !atomic_dec_and_test (&de->refcount) ) return;
     if (de == root_entry)
 	OOPS ("%s: devfs_put(): root entry being freed\n", DEVFS_NAME);
@@ -856,6 +875,7 @@
     if ( S_ISLNK (de->mode) ) stat_num_bytes -= de->u.symlink.length + 1;
     spin_unlock (&stat_lock);
 #endif
+    de->info = POISON_PTR;
     kfree (de);
 }   /*  End Function devfs_put  */
 
@@ -911,7 +931,7 @@
     if ( name && (namelen < 1) ) namelen = strlen (name);
     if ( ( new = kmalloc (sizeof *new + namelen, GFP_KERNEL) ) == NULL )
 	return NULL;
-    memset (new, 0, sizeof *new + namelen);
+    memset (new, 0, sizeof *new + namelen);  /*  Will set '\0' on name  */
     new->mode = mode;
     if ( S_ISDIR (mode) ) rwlock_init (&new->u.dir.lock);
     atomic_set (&new->refcount, 1);
@@ -936,7 +956,7 @@
  *	@de:  The devfs entry to append.
  *	@removable: If TRUE, increment the count of removable devices for %dir.
  *	@old_de: If an existing entry exists, it will be written here. This may
- *		 be %NULL.
+ *		 be %NULL. An implicit devfs_get() is performed on this entry.
  *
  *  Append a devfs entry to a directory's list of children, checking first to
  *   see if an entry of the same name exists. The directory will be locked.
@@ -1185,7 +1205,8 @@
  *	@type: The type of special file to search for. This may be either
  *		%DEVFS_SPECIAL_CHR or %DEVFS_SPECIAL_BLK.
  *
- *	Returns the devfs_entry pointer on success, else %NULL.
+ *	Returns the devfs_entry pointer on success, else %NULL. An implicit
+ *	devfs_get() is performed.
  */
 
 static struct devfs_entry *find_by_dev (struct devfs_entry *dir,
@@ -1241,23 +1262,20 @@
  *	find_entry - Find a devfs entry.
  *	@dir: The handle to the parent devfs directory entry. If this is %NULL the
  *		name is relative to the root of the devfs.
- *	@name: The name of the entry. This is ignored if @handle is not %NULL.
- *	@namelen: The number of characters in @name, not including a %NULL
- *		terminator. If this is 0, then @name must be %NULL-terminated and the
- *		length is computed internally.
- *	@major: The major number. This is used if @handle and @name are %NULL.
- *	@minor: The minor number. This is used if @handle and @name are %NULL.
+ *	@name: The name of the entry. This may be %NULL.
+ *	@major: The major number. This is used if lookup by @name fails.
+ *	@minor: The minor number. This is used if lookup by @name fails.
  *		NOTE: If @major and @minor are both 0, searching by major and minor
  *		numbers is disabled.
  *	@type: The type of special file to search for. This may be either
  *		%DEVFS_SPECIAL_CHR or %DEVFS_SPECIAL_BLK.
  *	@traverse_symlink: If %TRUE then symbolic links are traversed.
  *
- *	Returns the devfs_entry pointer on success, else %NULL.
+ *	Returns the devfs_entry pointer on success, else %NULL. An implicit
+ *	devfs_get() is performed.
  */
 
-static struct devfs_entry *find_entry (devfs_handle_t dir,
-				       const char *name, unsigned int namelen,
+static struct devfs_entry *find_entry (devfs_handle_t dir, const char *name,
 				       unsigned int major, unsigned int minor,
 				       char type, int traverse_symlink)
 {
@@ -1265,7 +1283,8 @@
 
     if (name != NULL)
     {
-	if (namelen < 1) namelen = strlen (name);
+	unsigned int namelen = strlen (name);
+
 	if (name[0] == '/')
 	{
 	    /*  Skip leading pathname component  */
@@ -1632,8 +1651,9 @@
 	if (!child) break;
 #ifdef CONFIG_DEVFS_DEBUG
 	if (devfs_debug & DEBUG_UNREGISTER)
-	    printk ("%s: unregister(): child->name: \"%s\" child: %p\n",
-		    DEVFS_NAME, child->name, child);
+	    printk ( "%s: unregister(%s): child: %p  refcount: %d\n",
+		     DEVFS_NAME, child->name, child,
+		     atomic_read (&de->refcount) );
 #endif
 	devfs_put (child);
     }
@@ -1643,7 +1663,7 @@
 /**
  *	devfs_unregister - Unregister a device entry.
  *	@de: A handle previously created by devfs_register() or returned from
- *		devfs_find_handle(). If this is %NULL the routine does nothing.
+ *		devfs_get_handle(). If this is %NULL the routine does nothing.
  */
 
 void devfs_unregister (devfs_handle_t de)
@@ -1651,8 +1671,8 @@
     if ( (de == NULL) || (de->parent == NULL) ) return;
 #ifdef CONFIG_DEVFS_DEBUG
     if (devfs_debug & DEBUG_UNREGISTER)
-	printk ("%s: devfs_unregister(): de->name: \"%s\" de: %p\n",
-		DEVFS_NAME, de->name, de);
+	printk ( "%s: devfs_unregister(%s): de: %p  refcount: %d\n",
+		 DEVFS_NAME, de->name, de, atomic_read (&de->refcount) );
 #endif
     write_lock (&de->parent->u.dir.lock);
     unregister (de->parent, de);
@@ -1763,7 +1783,7 @@
 devfs_handle_t devfs_mk_dir (devfs_handle_t dir, const char *name, void *info)
 {
     int err;
-    struct devfs_entry *de;
+    struct devfs_entry *de, *old;
 
     if (name == NULL)
     {
@@ -1777,10 +1797,21 @@
 	return NULL;
     }
     de->info = info;
-    if ( ( err = _devfs_append_entry (dir, de, FALSE, NULL) ) != 0 )
+    if ( ( err = _devfs_append_entry (dir, de, FALSE, &old) ) != 0 )
     {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,1)
+	if (old)
+	{
+	    printk("%s: devfs_mk_dir(%s): using old entry in dir: %p \"%s\"\n",
+		   DEVFS_NAME, name, dir, dir->name);
+	    old->vfs_created = FALSE;
+	    devfs_put (dir);
+	    return old;
+	}
+#endif
 	printk ("%s: devfs_mk_dir(%s): could not append to dir: %p \"%s\", err: %d\n",
 		DEVFS_NAME, name, dir, dir->name, err);
+	devfs_put (old);
 	devfs_put (dir);
 	return NULL;
     }
@@ -1796,7 +1827,7 @@
 
 
 /**
- *	devfs_find_handle - Find the handle of a devfs entry.
+ *	devfs_get_handle - Find the handle of a devfs entry.
  *	@dir: The handle to the parent devfs directory entry. If this is %NULL the
  *		name is relative to the root of the devfs.
  *	@name: The name of the entry.
@@ -1808,20 +1839,31 @@
  *		traversed. Symlinks pointing out of the devfs namespace will cause a
  *		failure. Symlink traversal consumes stack space.
  *
- *	Returns a handle which may later be used in a call to devfs_unregister(),
- *	devfs_get_flags(), or devfs_set_flags(). On failure %NULL is returned.
+ *	Returns a handle which may later be used in a call to
+ *	devfs_unregister(), devfs_get_flags(), or devfs_set_flags(). A
+ *	subsequent devfs_put() is required to decrement the refcount.
+ *	On failure %NULL is returned.
  */
 
+devfs_handle_t devfs_get_handle (devfs_handle_t dir, const char *name,
+				 unsigned int major, unsigned int minor,
+				 char type, int traverse_symlinks)
+{
+    if ( (name != NULL) && (name[0] == '\0') ) name = NULL;
+    return find_entry (dir, name, major, minor, type, traverse_symlinks);
+}   /*  End Function devfs_get_handle  */
+
+
+/*  Compatibility function. Will be removed in sometime in 2.5  */
+
 devfs_handle_t devfs_find_handle (devfs_handle_t dir, const char *name,
 				  unsigned int major, unsigned int minor,
 				  char type, int traverse_symlinks)
 {
     devfs_handle_t de;
 
-    if ( (name != NULL) && (name[0] == '\0') ) name = NULL;
-    de = find_entry (dir, name, 0, major, minor, type, traverse_symlinks);
-    devfs_put (de);  /*  FIXME: in 2.5 consider dropping this and require a
-			 call to devfs_put()  */
+    de = devfs_get_handle (dir, name, major, minor, type, traverse_symlinks);
+    devfs_put (de);
     return de;
 }   /*  End Function devfs_find_handle  */
 
@@ -1951,18 +1993,55 @@
  *	@de: The handle to the device entry.
  *
  *	Returns a pointer to the device operations on success, else NULL.
+ *	The use count for the module owning the operations will be incremented.
  */
 
 void *devfs_get_ops (devfs_handle_t de)
 {
+    struct module *owner;
+
     if (de == NULL) return NULL;
-    if ( S_ISCHR (de->mode) || S_ISBLK (de->mode) || S_ISREG (de->mode) )
-	return de->u.fcb.ops;
-    return NULL;
+    if ( !S_ISCHR (de->mode) && !S_ISBLK (de->mode) && !S_ISREG (de->mode) )
+	return NULL;
+    if (de->u.fcb.ops == NULL) return NULL;
+    read_lock (&de->parent->u.dir.lock);  /*  Prevent module from unloading  */
+    if (de->next == de) owner = NULL;     /*  Ops pointer is already stale   */
+    else if ( S_ISCHR (de->mode) || S_ISREG (de->mode) )
+	owner = ( (struct file_operations *) de->u.fcb.ops )->owner;
+    else owner = ( (struct block_device_operations *) de->u.fcb.ops )->owner;
+    if ( (de->next == de) || !try_inc_mod_count (owner) )
+    {   /*  Entry is already unhooked or module is unloading  */
+	read_unlock (&de->parent->u.dir.lock);
+	return NULL;
+    }
+    read_unlock (&de->parent->u.dir.lock);  /*  Module can continue unloading*/
+    return de->u.fcb.ops;
 }   /*  End Function devfs_get_ops  */
 
 
 /**
+ *	devfs_put_ops - Put the device operations for a devfs entry.
+ *	@de: The handle to the device entry.
+ *
+ *	The use count for the module owning the operations will be decremented.
+ */
+
+void devfs_put_ops (devfs_handle_t de)
+{
+    struct module *owner;
+
+    if (de == NULL) return;
+    if ( !S_ISCHR (de->mode) && !S_ISBLK (de->mode) && !S_ISREG (de->mode) )
+	return;
+    if (de->u.fcb.ops == NULL) return;
+    if ( S_ISCHR (de->mode) || S_ISREG (de->mode) )
+	owner = ( (struct file_operations *) de->u.fcb.ops )->owner;
+    else owner = ( (struct block_device_operations *) de->u.fcb.ops )->owner;
+    if (owner) __MOD_DEC_USE_COUNT (owner);
+}   /*  End Function devfs_put_ops  */
+
+
+/**
  *	devfs_set_file_size - Set the file size for a devfs regular file.
  *	@de: The handle to the device entry.
  *	@size: The new file size.
@@ -2244,10 +2323,12 @@
 
 __setup("devfs=", devfs_setup);
 
+EXPORT_SYMBOL(devfs_put);
 EXPORT_SYMBOL(devfs_register);
 EXPORT_SYMBOL(devfs_unregister);
 EXPORT_SYMBOL(devfs_mk_symlink);
 EXPORT_SYMBOL(devfs_mk_dir);
+EXPORT_SYMBOL(devfs_get_handle);
 EXPORT_SYMBOL(devfs_find_handle);
 EXPORT_SYMBOL(devfs_get_flags);
 EXPORT_SYMBOL(devfs_set_flags);
@@ -2312,14 +2393,17 @@
 static int check_disc_changed (struct devfs_entry *de)
 {
     int tmp;
+    int retval = 0;
     kdev_t dev = MKDEV (de->u.fcb.u.device.major, de->u.fcb.u.device.minor);
-    struct block_device_operations *bdops = de->u.fcb.ops;
+    struct block_device_operations *bdops;
     extern int warn_no_part;
 
     if ( !S_ISBLK (de->mode) ) return 0;
-    if (bdops == NULL) return 0;
-    if (bdops->check_media_change == NULL) return 0;
-    if ( !bdops->check_media_change (dev) ) return 0;
+    bdops = devfs_get_ops (de);
+    if (!bdops) return 0;
+    if (bdops->check_media_change == NULL) goto out;
+    if ( !bdops->check_media_change (dev) ) goto out;
+    retval = 1;
     printk ( KERN_DEBUG "VFS: Disk change detected on device %s\n",
 	     kdevname (dev) );
     if (invalidate_device(dev, 0))
@@ -2329,7 +2413,9 @@
     warn_no_part = 0;
     if (bdops->revalidate) bdops->revalidate (dev);
     warn_no_part = tmp;
-    return 1;
+out:
+    devfs_put_ops (de);
+    return retval;
 }   /*  End Function check_disc_changed  */
 
 
@@ -2433,7 +2519,7 @@
 static int devfs_statfs (struct super_block *sb, struct statfs *buf)
 {
     buf->f_type = DEVFS_SUPER_MAGIC;
-    buf->f_bsize = PAGE_SIZE / sizeof (long);
+    buf->f_bsize = FAKE_BLOCK_SIZE;
     buf->f_bfree = 0;
     buf->f_bavail = 0;
     buf->f_ffree = 0;
@@ -2498,7 +2584,7 @@
 		DEVFS_NAME, (int) inode->i_ino, inode, de);
 #endif
     inode->i_blocks = 0;
-    inode->i_blksize = 1024;
+    inode->i_blksize = FAKE_BLOCK_SIZE;
     inode->i_op = &devfs_iops;
     inode->i_fop = &devfs_fops;
     inode->i_rdev = NODEV;
diff -urN linux-2.4.17-rc1/fs/ntfs/Makefile linux/fs/ntfs/Makefile
--- linux-2.4.17-rc1/fs/ntfs/Makefile	Sun Sep 30 11:42:44 2001
+++ linux/fs/ntfs/Makefile	Tue Dec 18 13:40:18 2001
@@ -5,7 +5,7 @@
 obj-y   := fs.o sysctl.o support.o util.o inode.o dir.o super.o attr.o unistr.o
 obj-m   := $(O_TARGET)
 # New version format started 3 February 2001.
-EXTRA_CFLAGS = -DNTFS_VERSION=\"1.1.20\" #-DDEBUG
+EXTRA_CFLAGS = -DNTFS_VERSION=\"1.1.21\" #-DDEBUG
 
 include $(TOPDIR)/Rules.make
 
diff -urN linux-2.4.17-rc1/fs/ntfs/attr.c linux/fs/ntfs/attr.c
--- linux-2.4.17-rc1/fs/ntfs/attr.c	Sat Sep  8 12:24:40 2001
+++ linux/fs/ntfs/attr.c	Tue Dec 18 13:40:18 2001
@@ -548,7 +548,7 @@
  * attribute.
  */
 static int ntfs_process_runs(ntfs_inode *ino, ntfs_attribute* attr,
-			     unsigned char *data)
+		unsigned char *data)
 {
 	int startvcn, endvcn;
 	int vcn, cnum;
@@ -622,7 +622,7 @@
 }
   
 /* Insert the attribute starting at attr in the inode ino. */
-int ntfs_insert_attribute(ntfs_inode *ino, unsigned char* attrdata)
+int ntfs_insert_attribute(ntfs_inode *ino, unsigned char *attrdata)
 {
 	int i, found;
 	int type;
diff -urN linux-2.4.17-rc1/fs/ntfs/fs.c linux/fs/ntfs/fs.c
--- linux-2.4.17-rc1/fs/ntfs/fs.c	Thu Oct 25 00:02:26 2001
+++ linux/fs/ntfs/fs.c	Tue Dec 18 13:40:18 2001
@@ -303,10 +303,8 @@
 	ntfs_debug(DEBUG_OTHER, __FUNCTION__ "(): After ntfs_getdir_unsorted()"
 			" calls, f_pos 0x%Lx.\n", filp->f_pos);
 	if (!err) {
-#ifdef DEBUG
-		if (cb.ph != 0x7fff || cb.pl)
-			BUG();
 done:
+#ifdef DEBUG
 		if (!cb.ret_code)
 			ntfs_debug(DEBUG_OTHER, __FUNCTION__ "(): EOD, f_pos "
 					"0x%Lx, returning 0.\n", filp->f_pos);
@@ -314,8 +312,6 @@
 			ntfs_debug(DEBUG_OTHER, __FUNCTION__ "(): filldir "
 					"returned %i, returning 0, f_pos "
 					"0x%Lx.\n", cb.ret_code, filp->f_pos);
-#else
-done:
 #endif
 		return 0;
 	}
diff -urN linux-2.4.17-rc1/fs/ntfs/inode.c linux/fs/ntfs/inode.c
--- linux-2.4.17-rc1/fs/ntfs/inode.c	Sun Sep 30 11:42:44 2001
+++ linux/fs/ntfs/inode.c	Tue Dec 18 13:40:18 2001
@@ -159,7 +159,7 @@
  * Return 0 on success or -errno on error.
  */
 static int ntfs_insert_mft_attribute(ntfs_inode* ino, int mftno,
-				     ntfs_u8 *attr)
+		ntfs_u8 *attr)
 {
 	int i, error, present = 0;
 
@@ -207,6 +207,7 @@
 	int mftno, l, error;
 	int last_mft = -1;
 	int len = *plen;
+	int tries = 0;
 	
 	if (!ino->attr) {
 		ntfs_error("parse_attributes: called on inode 0x%x without a "
@@ -230,9 +231,13 @@
 			*   then occur there or the user notified to run
 			*   ntfsck. (AIA) */
 		if (mftno != ino->i_number && mftno != last_mft) {
+continue_after_loading_mft_data:
 			last_mft = mftno;
 			error = ntfs_read_mft_record(ino->vol, mftno, mft);
 			if (error) {
+				if (error == -EINVAL && !tries)
+					goto force_load_mft_data;
+failed_reading_mft_data:
 				ntfs_debug(DEBUG_FILE3, "parse_attributes: "
 					"ntfs_read_mft_record(mftno = 0x%x) "
 					"failed\n", mftno);
@@ -272,9 +277,106 @@
 	ntfs_free(mft);
 	*plen = len;
 	return 0;
+force_load_mft_data:
+{
+	ntfs_u8 *mft2, *attr2;
+	int mftno2;
+	int last_mft2 = last_mft;
+	int len2 = len;
+	int error2;
+	int found2 = 0;
+	ntfs_u8 *alist2 = alist;
+	/*
+	 * We only get here if $DATA wasn't found in $MFT which only happens
+	 * on volume mount when $MFT has an attribute list and there are
+	 * attributes before $DATA which are inside extent mft records. So
+	 * we just skip forward to the $DATA attribute and read that. Then we
+	 * restart which is safe as an attribute will not be inserted twice.
+	 *
+	 * This still will not fix the case where the attribute list is non-
+	 * resident, larger than 1024 bytes, and the $DATA attribute list entry
+	 * is not in the first 1024 bytes. FIXME: This should be implemented
+	 * somehow! Perhaps by passing special error code up to
+	 * ntfs_load_attributes() so it keeps going trying to get to $DATA
+	 * regardless. Then it would have to restart just like we do here.
+	 */
+	mft2 = ntfs_malloc(ino->vol->mft_record_size);
+	if (!mft2) {
+		ntfs_free(mft);
+		return -ENOMEM;
+	}
+	ntfs_memcpy(mft2, mft, ino->vol->mft_record_size);
+	while (len2 > 8) {
+		l = NTFS_GETU16(alist2 + 4);
+		if (l > len2)
+			break;
+		if (NTFS_GETU32(alist2 + 0x0) < ino->vol->at_data) {
+			len2 -= l;
+			alist2 += l;
+			continue;
+		}
+		if (NTFS_GETU32(alist2 + 0x0) > ino->vol->at_data) {
+			if (found2)
+				break;
+			/* Uh-oh! It really isn't there! */
+			ntfs_error("Either the $MFT is corrupt or, equally "
+					"likely, the $MFT is too complex for "
+					"the current driver to handle. Please "
+					"email the ntfs maintainer that you "
+					"saw this message. Thank you.\n");
+			goto failed_reading_mft_data;
+		}
+	        /* Process attribute description. */
+		mftno2 = NTFS_GETU32(alist2 + 0x10); 
+		if (mftno2 != ino->i_number && mftno2 != last_mft2) {
+			last_mft2 = mftno2;
+			error2 = ntfs_read_mft_record(ino->vol, mftno2, mft2);
+			if (error2) {
+				ntfs_debug(DEBUG_FILE3, "parse_attributes: "
+					"ntfs_read_mft_record(mftno2 = 0x%x) "
+					"failed\n", mftno2);
+				ntfs_free(mft2);
+				goto failed_reading_mft_data;
+			}
+		}
+		attr2 = ntfs_find_attr_in_mft_rec(
+				ino->vol,		 /* ntfs volume */
+				mftno2 == ino->i_number ?/* mft record is: */
+					ino->attr:	 /*  base record */
+					mft2,		 /*  extension record */
+				NTFS_GETU32(alist2 + 0),	/* type */
+				(wchar_t*)(alist2 + alist2[7]),	/* name */
+				alist2[6], 		 /* name length */
+				1,			 /* ignore case */
+				NTFS_GETU16(alist2 + 24) /* instance number */
+				);
+		if (!attr2) {
+			ntfs_error("parse_attributes: mft records 0x%x and/or "
+				       "0x%x corrupt!\n", ino->i_number,
+				       mftno2);
+			ntfs_free(mft2);
+			goto failed_reading_mft_data;
+		}
+		error2 = ntfs_insert_mft_attribute(ino, mftno2, attr2);
+		if (error2) {
+			ntfs_debug(DEBUG_FILE3, "parse_attributes: "
+				"ntfs_insert_mft_attribute(mftno2 0x%x, "
+				"attribute2 type 0x%x) failed\n", mftno2,
+				NTFS_GETU32(alist2 + 0));
+			ntfs_free(mft2);
+			goto failed_reading_mft_data;
+		}
+		len2 -= l;
+		alist2 += l;
+		found2 = 1;
+	}
+	ntfs_free(mft2);
+	tries = 1;
+	goto continue_after_loading_mft_data;
+}
 }
 
-static void ntfs_load_attributes(ntfs_inode* ino)
+static void ntfs_load_attributes(ntfs_inode *ino)
 {
 	ntfs_attribute *alist;
 	int datasize;
diff -urN linux-2.4.17-rc1/fs/ntfs/support.c linux/fs/ntfs/support.c
--- linux-2.4.17-rc1/fs/ntfs/support.c	Tue Sep 11 17:02:46 2001
+++ linux/fs/ntfs/support.c	Tue Dec 18 13:40:18 2001
@@ -150,7 +150,7 @@
 		 * now as we just can't handle some on disk structures
 		 * this way. (AIA) */
 		printk(KERN_WARNING "NTFS: Invalid MFT record for 0x%x\n", mftno);
-		return -EINVAL;
+		return -EIO;
 	}
 	ntfs_debug(DEBUG_OTHER, "read_mft_record: Done 0x%x\n", mftno);
 	return 0;
diff -urN linux-2.4.17-rc1/fs/reiserfs/procfs.c linux/fs/reiserfs/procfs.c
--- linux-2.4.17-rc1/fs/reiserfs/procfs.c	Fri Nov  9 14:18:25 2001
+++ linux/fs/reiserfs/procfs.c	Tue Dec 18 13:40:18 2001
@@ -15,6 +15,7 @@
 #include <linux/sched.h>
 #include <asm/uaccess.h>
 #include <linux/reiserfs_fs.h>
+#include <linux/reiserfs_fs_sb.h>
 #include <linux/smp_lock.h>
 #include <linux/locks.h>
 #include <linux/init.h>
@@ -76,12 +77,20 @@
 {
 	int len = 0;
 	struct super_block *sb;
+	char *format;
     
 	sb = procinfo_prologue( ( kdev_t ) ( int ) data );
 	if( sb == NULL )
 		return -ENOENT;
+	if ( sb->u.reiserfs_sb.s_properties & (1 << REISERFS_3_6) ) {
+		format = "3.6";
+	} else if ( sb->u.reiserfs_sb.s_properties & (1 << REISERFS_3_5) ) {
+		format = "3.5";
+	} else {
+		format = "unknown";
+	}
 	len += sprintf( &buffer[ len ], "%s format\twith checks %s\n",
-			old_format_only( sb ) ? "old" : "new",
+			format,
 #if defined( CONFIG_REISERFS_CHECK )
 			"on"
 #else
@@ -179,7 +188,7 @@
 			dont_have_tails( sb ) ? "NO_TAILS " : "TAILS ",
 			replay_only( sb ) ? "REPLAY_ONLY " : "",
 			reiserfs_dont_log( sb ) ? "DONT_LOG " : "LOG ",
-			old_format_only( sb ) ? "CONV " : "",
+			convert_reiserfs( sb ) ? "CONV " : "",
 
 			atomic_read( &r -> s_generation_counter ),
 			SF( s_kmallocs ),
diff -urN linux-2.4.17-rc1/fs/reiserfs/super.c linux/fs/reiserfs/super.c
--- linux-2.4.17-rc1/fs/reiserfs/super.c	Tue Dec 18 13:40:14 2001
+++ linux/fs/reiserfs/super.c	Tue Dec 18 13:40:18 2001
@@ -888,6 +888,8 @@
     unsigned long blocks;
     int jinit_done = 0 ;
     struct reiserfs_iget4_args args ;
+    int old_magic;
+    struct reiserfs_super_block * rs;
 
 
     memset (&s->u.reiserfs_sb, 0, sizeof (struct reiserfs_sb_info));
@@ -972,18 +974,15 @@
       goto error ;
     }
 
-    if (!(s->s_flags & MS_RDONLY)) {
-	struct reiserfs_super_block * rs = SB_DISK_SUPER_BLOCK (s);
-        int old_magic;
-
-      old_magic = strncmp (rs->s_magic,  REISER2FS_SUPER_MAGIC_STRING,
+    rs = SB_DISK_SUPER_BLOCK (s);
+    old_magic = strncmp (rs->s_magic,  REISER2FS_SUPER_MAGIC_STRING,
                            strlen ( REISER2FS_SUPER_MAGIC_STRING));
-	if( old_magic && le16_to_cpu(rs->s_version) != 0 ) {
-	  dput(s->s_root) ;
-	  s->s_root = NULL ;
-	  reiserfs_warning("reiserfs: wrong version/magic combination in the super-block\n") ;
-	  goto error ;
-	}
+    if (!old_magic)
+	set_bit(REISERFS_3_6, &(s->u.reiserfs_sb.s_properties));
+    else
+	set_bit(REISERFS_3_5, &(s->u.reiserfs_sb.s_properties));
+
+    if (!(s->s_flags & MS_RDONLY)) {
 
 	journal_begin(&th, s, 1) ;
 	reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ;
@@ -992,24 +991,20 @@
 
         if ( old_magic ) {
 	    // filesystem created under 3.5.x found
-	    if (!old_format_only (s)) {
+	    if (convert_reiserfs (s)) {
 		reiserfs_warning("reiserfs: converting 3.5.x filesystem to the new format\n") ;
 		// after this 3.5.x will not be able to mount this partition
 		memcpy (rs->s_magic, REISER2FS_SUPER_MAGIC_STRING, 
 			sizeof (REISER2FS_SUPER_MAGIC_STRING));
 
 		reiserfs_convert_objectid_map_v1(s) ;
+		set_bit(REISERFS_3_6, &(s->u.reiserfs_sb.s_properties));
+		clear_bit(REISERFS_3_5, &(s->u.reiserfs_sb.s_properties));
 	    } else {
 		reiserfs_warning("reiserfs: using 3.5.x disk format\n") ;
 	    }
-	} else {
-	    // new format found
-	    set_bit (REISERFS_CONVERT, &(s->u.reiserfs_sb.s_mount_opt));
 	}
 
-	// mark hash in super block: it could be unset. overwrite should be ok
-        set_sb_hash_function_code( rs, function2code(s->u.reiserfs_sb.s_hash_function ) );
-
 	journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
 	journal_end(&th, s, 1) ;
 	
@@ -1018,12 +1013,12 @@
 
 	s->s_dirt = 0;
     } else {
-	struct reiserfs_super_block * rs = SB_DISK_SUPER_BLOCK (s);
-	if (strncmp (rs->s_magic,  REISER2FS_SUPER_MAGIC_STRING, 
-		     strlen ( REISER2FS_SUPER_MAGIC_STRING))) {
+	if ( old_magic ) {
 	    reiserfs_warning("reiserfs: using 3.5.x disk format\n") ;
 	}
     }
+    // mark hash in super block: it could be unset. overwrite should be ok
+    set_sb_hash_function_code( rs, function2code(s->u.reiserfs_sb.s_hash_function ) );
 
     reiserfs_proc_info_init( s );
     reiserfs_proc_register( s, "version", reiserfs_version_in_proc );
diff -urN linux-2.4.17-rc1/fs/super.c linux/fs/super.c
--- linux-2.4.17-rc1/fs/super.c	Mon Nov 26 05:29:17 2001
+++ linux/fs/super.c	Tue Dec 18 13:40:18 2001
@@ -537,6 +537,7 @@
 	struct inode *inode;
 	struct block_device *bdev;
 	struct block_device_operations *bdops;
+	devfs_handle_t de;
 	struct super_block * s;
 	struct nameidata nd;
 	struct list_head *p;
@@ -560,13 +561,15 @@
 		goto out;
 	bd_acquire(inode);
 	bdev = inode->i_bdev;
-	bdops = devfs_get_ops ( devfs_get_handle_from_inode (inode) );
+	de = devfs_get_handle_from_inode (inode);
+	bdops = devfs_get_ops (de);         /*  Increments module use count  */
 	if (bdops) bdev->bd_op = bdops;
 	/* Done with lookups, semaphore down */
 	dev = to_kdev_t(bdev->bd_dev);
 	if (!(flags & MS_RDONLY))
 		mode |= FMODE_WRITE;
 	error = blkdev_get(bdev, mode, 0, BDEV_FS);
+	devfs_put_ops (de);   /*  Decrement module use count now we're safe  */
 	if (error)
 		goto out;
 	check_disk_change(dev);
@@ -999,12 +1002,13 @@
 	bdev = bdget(kdev_t_to_nr(ROOT_DEV));
 	if (!bdev)
 		panic(__FUNCTION__ ": unable to allocate root device");
-	bdev->bd_op = devfs_get_ops (handle);
+	bdev->bd_op = devfs_get_ops (handle); /* Increments module use count */
 	path_start = devfs_generate_path (handle, path + 5, sizeof (path) - 5);
 	mode = FMODE_READ;
 	if (!(root_mountflags & MS_RDONLY))
 		mode |= FMODE_WRITE;
 	retval = blkdev_get(bdev, mode, 0, BDEV_FS);
+	devfs_put_ops (handle); /* Decrement module use count now we're safe */
 	if (retval == -EROFS) {
 		root_mountflags |= MS_RDONLY;
 		goto retry;
diff -urN linux-2.4.17-rc1/fs/sysv/ChangeLog linux/fs/sysv/ChangeLog
--- linux-2.4.17-rc1/fs/sysv/ChangeLog	Fri Nov  9 13:45:35 2001
+++ linux/fs/sysv/ChangeLog	Tue Dec 18 13:40:18 2001
@@ -1,3 +1,12 @@
+Sat Dec 15 2001  Christoph Hellwig  <hch@caldera.de>
+
+	* inode.c (sysv_read_inode): Mark inode as bad in case of failure.
+	* super.c (complete_read_super): Check for bad root inode.
+
+Wed Nov 21 2001  Andrew Morton  <andrewm@uow.edu.au>
+
+	* file.c (sysv_sync_file): Call fsync_inode_data_buffers.
+
 Fri Oct 26 2001  Christoph Hellwig  <hch@caldera.de>
 
 	* dir.c, ialloc.c, namei.c, include/linux/sysv_fs_i.h:
diff -urN linux-2.4.17-rc1/fs/sysv/inode.c linux/fs/sysv/inode.c
--- linux-2.4.17-rc1/fs/sysv/inode.c	Fri Nov  9 13:45:35 2001
+++ linux/fs/sysv/inode.c	Tue Dec 18 13:40:18 2001
@@ -152,13 +152,13 @@
 		printk("Bad inode number on dev %s"
 		       ": %d is out of range\n",
 		       kdevname(inode->i_dev), ino);
-		return;
+		goto bad_inode;
 	}
 	raw_inode = sysv_raw_inode(sb, ino, &bh);
 	if (!raw_inode) {
 		printk("Major problem: unable to read inode from dev %s\n",
 		       bdevname(inode->i_dev));
-		return;
+		goto bad_inode;
 	}
 	/* SystemV FS: kludge permissions if ino==SYSV_ROOT_INO ?? */
 	inode->i_mode = fs16_to_cpu(sb, raw_inode->i_mode);
@@ -178,6 +178,11 @@
 		rdev = (u16)fs32_to_cpu(sb, inode->u.sysv_i.i_data[0]);
 	inode->u.sysv_i.i_dir_start_lookup = 0;
 	sysv_set_inode(inode, rdev);
+	return;
+
+bad_inode:
+	make_bad_inode(inode);
+	return;
 }
 
 static struct buffer_head * sysv_update_inode(struct inode * inode)
diff -urN linux-2.4.17-rc1/fs/sysv/super.c linux/fs/sysv/super.c
--- linux-2.4.17-rc1/fs/sysv/super.c	Fri Nov  9 13:45:35 2001
+++ linux/fs/sysv/super.c	Tue Dec 18 13:40:18 2001
@@ -325,7 +325,7 @@
 	/* set up enough so that it can read an inode */
 	sb->s_op = &sysv_sops;
 	root_inode = iget(sb,SYSV_ROOT_INO);
-	if (!root_inode) {
+	if (!root_inode || is_bad_inode(root_inode)) {
 		printk("SysV FS: get root inode failed\n");
 		return 0;
 	}
diff -urN linux-2.4.17-rc1/include/linux/devfs_fs.h linux/include/linux/devfs_fs.h
--- linux-2.4.17-rc1/include/linux/devfs_fs.h	Fri Sep 21 10:55:23 2001
+++ linux/include/linux/devfs_fs.h	Tue Dec 18 13:40:21 2001
@@ -26,7 +26,7 @@
 					      binary interface will change   */
 
 struct devfsd_notify_struct
-{
+{   /*  Use native C types to ensure same types in kernel and user space     */
     unsigned int type;           /*  DEVFSD_NOTIFY_* value                   */
     unsigned int mode;           /*  Mode of the inode or device entry       */
     unsigned int major;          /*  Major number of device entry            */
diff -urN linux-2.4.17-rc1/include/linux/devfs_fs_kernel.h linux/include/linux/devfs_fs_kernel.h
--- linux-2.4.17-rc1/include/linux/devfs_fs_kernel.h	Tue Dec 18 13:40:14 2001
+++ linux/include/linux/devfs_fs_kernel.h	Tue Dec 18 13:40:21 2001
@@ -68,6 +68,7 @@
 
 #define UNIQUE_NUMBERSPACE_INITIALISER {SPIN_LOCK_UNLOCKED, 0, 0, 0, NULL}
 
+extern void devfs_put (devfs_handle_t de);
 extern devfs_handle_t devfs_register (devfs_handle_t dir, const char *name,
 				      unsigned int flags,
 				      unsigned int major, unsigned int minor,
@@ -78,6 +79,9 @@
 			     devfs_handle_t *handle, void *info);
 extern devfs_handle_t devfs_mk_dir (devfs_handle_t dir, const char *name,
 				    void *info);
+extern devfs_handle_t devfs_get_handle (devfs_handle_t dir, const char *name,
+					unsigned int major,unsigned int minor,
+					char type, int traverse_symlinks);
 extern devfs_handle_t devfs_find_handle (devfs_handle_t dir, const char *name,
 					 unsigned int major,unsigned int minor,
 					 char type, int traverse_symlinks);
@@ -88,6 +92,7 @@
 extern devfs_handle_t devfs_get_handle_from_inode (struct inode *inode);
 extern int devfs_generate_path (devfs_handle_t de, char *path, int buflen);
 extern void *devfs_get_ops (devfs_handle_t de);
+extern void devfs_put_ops (devfs_handle_t de);
 extern int devfs_set_file_size (devfs_handle_t de, unsigned long size);
 extern void *devfs_get_info (devfs_handle_t de);
 extern int devfs_set_info (devfs_handle_t de, void *info);
@@ -130,6 +135,10 @@
 
 #define UNIQUE_NUMBERSPACE_INITIALISER {0}
 
+static inline void devfs_put (devfs_handle_t de)
+{
+    return;
+}
 static inline devfs_handle_t devfs_register (devfs_handle_t dir,
 					     const char *name,
 					     unsigned int flags,
@@ -155,6 +164,15 @@
 {
     return NULL;
 }
+static inline devfs_handle_t devfs_get_handle (devfs_handle_t dir,
+					       const char *name,
+					       unsigned int major,
+					       unsigned int minor,
+					       char type,
+					       int traverse_symlinks)
+{
+    return NULL;
+}
 static inline devfs_handle_t devfs_find_handle (devfs_handle_t dir,
 						const char *name,
 						unsigned int major,
@@ -189,6 +207,10 @@
 static inline void *devfs_get_ops (devfs_handle_t de)
 {
     return NULL;
+}
+static inline void devfs_put_ops (devfs_handle_t de)
+{
+    return;
 }
 static inline int devfs_set_file_size (devfs_handle_t de, unsigned long size)
 {
diff -urN linux-2.4.17-rc1/include/linux/reiserfs_fs_sb.h linux/include/linux/reiserfs_fs_sb.h
--- linux-2.4.17-rc1/include/linux/reiserfs_fs_sb.h	Tue Dec 18 13:40:14 2001
+++ linux/include/linux/reiserfs_fs_sb.h	Tue Dec 18 13:40:21 2001
@@ -407,6 +407,8 @@
 				/* To be obsoleted soon by per buffer seals.. -Hans */
     atomic_t s_generation_counter; // increased by one every time the
     // tree gets re-balanced
+    unsigned int s_properties;    /* File system properties. Currently holds
+				     on-disk FS format */
     
     /* session statistics */
     int s_kmallocs;
@@ -428,7 +430,11 @@
     struct proc_dir_entry *procdir;
 };
 
+/* Definitions of reiserfs on-disk properties: */
+#define REISERFS_3_5 0
+#define REISERFS_3_6 1
 
+/* Mount options */
 #define NOTAIL 0  /* -o notail: no tails will be created in a session */
 #define REPLAYONLY 3 /* replay journal and return 0. Use by fsck */
 #define REISERFS_NOLOG 4      /* -o nolog: turn journalling off */
@@ -478,7 +484,8 @@
 #define dont_have_tails(s) ((s)->u.reiserfs_sb.s_mount_opt & (1 << NOTAIL))
 #define replay_only(s) ((s)->u.reiserfs_sb.s_mount_opt & (1 << REPLAYONLY))
 #define reiserfs_dont_log(s) ((s)->u.reiserfs_sb.s_mount_opt & (1 << REISERFS_NOLOG))
-#define old_format_only(s) ((SB_VERSION(s) != REISERFS_VERSION_2) && !((s)->u.reiserfs_sb.s_mount_opt & (1 << REISERFS_CONVERT)))
+#define old_format_only(s) ((s)->u.reiserfs_sb.s_properties & (1 << REISERFS_3_5))
+#define convert_reiserfs(s) ((s)->u.reiserfs_sb.s_mount_opt & (1 << REISERFS_CONVERT))
 
 
 void reiserfs_file_buffer (struct buffer_head * bh, int list);
diff -urN linux-2.4.17-rc1/include/linux/sched.h linux/include/linux/sched.h
--- linux-2.4.17-rc1/include/linux/sched.h	Thu Nov 22 11:46:19 2001
+++ linux/include/linux/sched.h	Tue Dec 18 13:40:21 2001
@@ -426,6 +426,7 @@
 #define PF_MEMALLOC	0x00000800	/* Allocating memory */
 #define PF_MEMDIE	0x00001000	/* Killed for out-of-memory */
 #define PF_FREE_PAGES	0x00002000	/* per process page freeing */
+#define PF_NOIO		0x00004000	/* avoid generating further I/O */
 
 #define PF_USEDFPU	0x00100000	/* task used FPU this quantum (SMP) */
 
diff -urN linux-2.4.17-rc1/mm/filemap.c linux/mm/filemap.c
--- linux-2.4.17-rc1/mm/filemap.c	Tue Dec 18 13:40:14 2001
+++ linux/mm/filemap.c	Tue Dec 18 13:40:23 2001
@@ -2854,7 +2854,7 @@
 	unsigned long	limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
 	loff_t		pos;
 	struct page	*page, *cached_page;
-	unsigned long	written;
+	ssize_t		written;
 	long		status = 0;
 	int		err;
 	unsigned	bytes;
diff -urN linux-2.4.17-rc1/mm/swapfile.c linux/mm/swapfile.c
--- linux-2.4.17-rc1/mm/swapfile.c	Sat Nov  3 17:05:25 2001
+++ linux/mm/swapfile.c	Tue Dec 18 13:40:23 2001
@@ -917,16 +917,19 @@
 	if (S_ISBLK(swap_inode->i_mode)) {
 		kdev_t dev = swap_inode->i_rdev;
 		struct block_device_operations *bdops;
+		devfs_handle_t de;
 
 		p->swap_device = dev;
 		set_blocksize(dev, PAGE_SIZE);
 		
 		bd_acquire(swap_inode);
 		bdev = swap_inode->i_bdev;
-		bdops = devfs_get_ops(devfs_get_handle_from_inode(swap_inode));
+		de = devfs_get_handle_from_inode(swap_inode);
+		bdops = devfs_get_ops(de);  /*  Increments module use count  */
 		if (bdops) bdev->bd_op = bdops;
 
 		error = blkdev_get(bdev, FMODE_READ|FMODE_WRITE, 0, BDEV_SWAP);
+		devfs_put_ops(de);/*Decrement module use count now we're safe*/
 		if (error)
 			goto bad_swap_2;
 		set_blocksize(dev, PAGE_SIZE);
diff -urN linux-2.4.17-rc1/mm/vmscan.c linux/mm/vmscan.c
--- linux-2.4.17-rc1/mm/vmscan.c	Sat Nov 17 19:18:17 2001
+++ linux/mm/vmscan.c	Tue Dec 18 13:40:23 2001
@@ -338,7 +338,7 @@
 {
 	struct list_head * entry;
 	int max_scan = nr_inactive_pages / priority;
-	int max_mapped = nr_pages << (9 - priority);
+	int max_mapped = min((nr_pages << (10 - priority)), max_scan / 10);
 
 	spin_lock(&pagemap_lru_lock);
 	while (--max_scan >= 0 && (entry = inactive_list.prev) != &inactive_list) {
diff -urN linux-2.4.17-rc1/net/ipv4/netfilter/ipt_TOS.c linux/net/ipv4/netfilter/ipt_TOS.c
--- linux-2.4.17-rc1/net/ipv4/netfilter/ipt_TOS.c	Tue Dec 18 13:40:14 2001
+++ linux/net/ipv4/netfilter/ipt_TOS.c	Tue Dec 18 13:40:23 2001
@@ -27,8 +27,8 @@
 			struct sk_buff *nskb = skb_copy(*pskb, GFP_ATOMIC);
 			if (!nskb)
 				return NF_DROP;
-			*pskb = nskb;
 			kfree_skb(*pskb);
+			*pskb = nskb;
 			iph = (*pskb)->nh.iph;
 		}
 
