## Automatically generated incremental diff
## From:   linux-2.4.28-bk4
## To:     linux-2.4.28-bk5
## Robot:  $Id: make-incremental-diff,v 1.12 2004/01/06 07:19:36 hpa Exp $

diff -urN linux-2.4.28-bk4/CREDITS linux-2.4.28-bk5/CREDITS
--- linux-2.4.28-bk4/CREDITS	2004-11-17 03:54:20.000000000 -0800
+++ linux-2.4.28-bk5/CREDITS	2004-11-24 02:49:31.720963074 -0800
@@ -1447,8 +1447,9 @@
 S: Germany
 
 N: Mike Jagdis
-E: jaggy@purplet.demon.co.uk
-E: Mike.Jagdis@purplet.demon.co.uk
+E: mjagdis@eris-associates.co.uk
+E: jaggy@jaggycraft.co.uk
+E: Mike.Jagdis@eris-associates.co.uk
 D: iBCS personalities, socket and X interfaces, x.out loader, syscalls...
 D: Purple Distribution maintainer
 D: UK FidoNet support
@@ -1457,7 +1458,7 @@
 S: 280 Silverdale Road
 S: Earley
 S: Reading
-S: RG6 2NU
+S: RG6 7NU
 S: United Kingdom
 
 N: Jakub Jelinek
diff -urN linux-2.4.28-bk4/MAINTAINERS linux-2.4.28-bk5/MAINTAINERS
--- linux-2.4.28-bk4/MAINTAINERS	2004-11-24 02:49:28.809845353 -0800
+++ linux-2.4.28-bk5/MAINTAINERS	2004-11-24 02:49:32.001974437 -0800
@@ -976,11 +976,12 @@
 S:	Supported
 
 INTERMEZZO FILE SYSTEM
-P:	Chen Yang
-M:	intermezzo-devel@lists.sourceforge.net
+P:	Peter J. Braam
+M:	braam@clusterfs.com
 W:      http://www.inter-mezzo.org/
+W:	http://sourceforge.net/projects/intermezzo/
 L:      intermezzo-discuss@lists.sourceforge.net
-S:      Maintained
+S:	Orphan
 
 IOC3 DRIVER
 P:	Ralf Baechle
diff -urN linux-2.4.28-bk4/Makefile linux-2.4.28-bk5/Makefile
--- linux-2.4.28-bk4/Makefile	2004-11-24 02:49:28.809845353 -0800
+++ linux-2.4.28-bk5/Makefile	2004-11-24 02:49:32.002974478 -0800
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 4
 SUBLEVEL = 28
-EXTRAVERSION = -bk4
+EXTRAVERSION = -bk5
 
 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 
diff -urN linux-2.4.28-bk4/arch/i386/kernel/pci-pc.c linux-2.4.28-bk5/arch/i386/kernel/pci-pc.c
--- linux-2.4.28-bk4/arch/i386/kernel/pci-pc.c	2004-11-24 02:49:28.812845475 -0800
+++ linux-2.4.28-bk5/arch/i386/kernel/pci-pc.c	2004-11-17 03:54:21.000000000 -0800
@@ -594,7 +594,7 @@
 	unsigned long flags;
 
 	__save_flags(flags); __cli();
-	__asm__("lcall *(%%edi); cld"
+	__asm__("lcall (%%edi); cld"
 		: "=a" (return_code),
 		  "=b" (address),
 		  "=c" (length),
@@ -635,7 +635,7 @@
 
 		__save_flags(flags); __cli();
 		__asm__(
-			"lcall *(%%edi); cld\n\t"
+			"lcall (%%edi); cld\n\t"
 			"jc 1f\n\t"
 			"xor %%ah, %%ah\n"
 			"1:"
@@ -680,7 +680,7 @@
 	unsigned short bx;
 	unsigned short ret;
 
-	__asm__("lcall *(%%edi); cld\n\t"
+	__asm__("lcall (%%edi); cld\n\t"
 		"jc 1f\n\t"
 		"xor %%ah, %%ah\n"
 		"1:"
@@ -709,7 +709,7 @@
 
 	switch (len) {
 	case 1:
-		__asm__("lcall *(%%esi); cld\n\t"
+		__asm__("lcall (%%esi); cld\n\t"
 			"jc 1f\n\t"
 			"xor %%ah, %%ah\n"
 			"1:"
@@ -721,7 +721,7 @@
 			  "S" (&pci_indirect));
 		break;
 	case 2:
-		__asm__("lcall *(%%esi); cld\n\t"
+		__asm__("lcall (%%esi); cld\n\t"
 			"jc 1f\n\t"
 			"xor %%ah, %%ah\n"
 			"1:"
@@ -733,7 +733,7 @@
 			  "S" (&pci_indirect));
 		break;
 	case 4:
-		__asm__("lcall *(%%esi); cld\n\t"
+		__asm__("lcall (%%esi); cld\n\t"
 			"jc 1f\n\t"
 			"xor %%ah, %%ah\n"
 			"1:"
@@ -764,7 +764,7 @@
 
 	switch (len) {
 	case 1:
-		__asm__("lcall *(%%esi); cld\n\t"
+		__asm__("lcall (%%esi); cld\n\t"
 			"jc 1f\n\t"
 			"xor %%ah, %%ah\n"
 			"1:"
@@ -776,7 +776,7 @@
 			  "S" (&pci_indirect));
 		break;
 	case 2:
-		__asm__("lcall *(%%esi); cld\n\t"
+		__asm__("lcall (%%esi); cld\n\t"
 			"jc 1f\n\t"
 			"xor %%ah, %%ah\n"
 			"1:"
@@ -788,7 +788,7 @@
 			  "S" (&pci_indirect));
 		break;
 	case 4:
-		__asm__("lcall *(%%esi); cld\n\t"
+		__asm__("lcall (%%esi); cld\n\t"
 			"jc 1f\n\t"
 			"xor %%ah, %%ah\n"
 			"1:"
@@ -1011,7 +1011,7 @@
 	__asm__("push %%es\n\t"
 		"push %%ds\n\t"
 		"pop  %%es\n\t"
-		"lcall *(%%esi); cld\n\t"
+		"lcall (%%esi); cld\n\t"
 		"pop %%es\n\t"
 		"jc 1f\n\t"
 		"xor %%ah, %%ah\n"
@@ -1047,7 +1047,7 @@
 {
 	int ret;
 
-	__asm__("lcall *(%%esi); cld\n\t"
+	__asm__("lcall (%%esi); cld\n\t"
 		"jc 1f\n\t"
 		"xor %%ah, %%ah\n"
 		"1:"
diff -urN linux-2.4.28-bk4/drivers/acpi/motherboard.c linux-2.4.28-bk5/drivers/acpi/motherboard.c
--- linux-2.4.28-bk4/drivers/acpi/motherboard.c	2004-11-17 03:54:21.000000000 -0800
+++ linux-2.4.28-bk5/drivers/acpi/motherboard.c	2004-11-24 02:49:32.376989603 -0800
@@ -17,6 +17,8 @@
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
+/* Purpose: Prevent PCMCIA cards from using motherboard resources. */
+
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/types.h>
@@ -43,9 +45,17 @@
 	(((len) > 0) && ((base) > 0) && ((base) + (len) < IO_SPACE_LIMIT) \
 	&& ((base) + (len) > PCIBIOS_MIN_IO))
 
+/*
+ * Clearing the flag (IORESOURCE_BUSY) allows drivers to use
+ * the io ports if they really know they can use it, while
+ * still preventing hotplug PCI devices from using it. 
+ */
+
 static acpi_status
 acpi_reserve_io_ranges (struct acpi_resource *res, void *data)
 {
+	struct resource *requested_res = NULL;
+
 	ACPI_FUNCTION_TRACE("acpi_reserve_io_ranges");
 
 	if (res->id == ACPI_RSTYPE_IO) {
@@ -57,23 +67,25 @@
 			ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Motherboard resources 0x%08x - 0x%08x\n",
 				io_res->min_base_address, 
 				io_res->min_base_address + io_res->range_length));
-			request_region(io_res->min_base_address, 
+			requested_res = request_region(io_res->min_base_address, 
 				io_res->range_length, "motherboard");
 		}
-	}else if (res->id == ACPI_RSTYPE_FIXED_IO) {
+	} else if (res->id == ACPI_RSTYPE_FIXED_IO) {
 		struct acpi_resource_fixed_io *fixed_io_res = &res->data.fixed_io;
 
 		if (IS_RESERVED_ADDR(fixed_io_res->base_address, fixed_io_res->range_length)) {
 			ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Motherboard resources 0x%08x - 0x%08x\n",
 				fixed_io_res->base_address, 
 				fixed_io_res->base_address + fixed_io_res->range_length));
-			request_region(fixed_io_res->base_address, 
+			requested_res = request_region(fixed_io_res->base_address, 
 				fixed_io_res->range_length, "motherboard");
 		}
-	}else {
+	} else {
 		/* Memory mapped IO? */
 	}
 
+	if (requested_res)
+		requested_res->flags &= ~IORESOURCE_BUSY;
 	return AE_OK;
 }
 
diff -urN linux-2.4.28-bk4/drivers/atm/Makefile linux-2.4.28-bk5/drivers/atm/Makefile
--- linux-2.4.28-bk4/drivers/atm/Makefile	2003-11-28 10:26:19.000000000 -0800
+++ linux-2.4.28-bk5/drivers/atm/Makefile	2004-11-24 02:49:32.376989603 -0800
@@ -92,7 +92,7 @@
 # deal with the various suffixes of the binary firmware images
 %.bin %.bin1 %.bin2: %.data
 	objcopy -Iihex $< -Obinary $@.gz
-	gzip -df $@.gz
+	gzip -n -df $@.gz
 
 fore_200e.o: $(fore_200e-objs)
 	$(LD) -r -o $@ $(fore_200e-objs)
diff -urN linux-2.4.28-bk4/drivers/net/wd.c linux-2.4.28-bk5/drivers/net/wd.c
--- linux-2.4.28-bk4/drivers/net/wd.c	2002-11-28 15:53:14.000000000 -0800
+++ linux-2.4.28-bk5/drivers/net/wd.c	2004-11-24 02:49:32.437992069 -0800
@@ -151,7 +151,7 @@
 		printk(" %2.2X", dev->dev_addr[i] = inb(ioaddr + 8 + i));
 
 	/* The following PureData probe code was contributed by
-	   Mike Jagdis <jaggy@purplet.demon.co.uk>. Puredata does software
+	   Mike Jagdis <mjagdis@eris-associates.co.uk>. Puredata does software
 	   configuration differently from others so we have to check for them.
 	   This detects an 8 bit, 16 bit or dumb (Toshiba, jumpered) card.
 	   */
diff -urN linux-2.4.28-bk4/drivers/usb/host/usb-ohci.c linux-2.4.28-bk5/drivers/usb/host/usb-ohci.c
--- linux-2.4.28-bk4/drivers/usb/host/usb-ohci.c	2004-04-14 06:05:33.000000000 -0700
+++ linux-2.4.28-bk5/drivers/usb/host/usb-ohci.c	2004-11-24 02:49:32.512995102 -0800
@@ -143,7 +143,7 @@
 		ohci->complete_head = urb;
 		ohci->complete_tail = urb;
 	} else {
-		ohci->complete_head->hcpriv = urb;
+		ohci->complete_tail->hcpriv = urb;
 		ohci->complete_tail = urb;
 	}
 }
@@ -677,7 +677,8 @@
 		return -ENOMEM;
 	}
 	memset (urb_priv, 0, sizeof (urb_priv_t) + size * sizeof (td_t *));
-	
+	init_waitqueue_head (&urb_priv->wait);
+
 	/* fill the private part of the URB */
 	urb_priv->length = size;
 	urb_priv->ed = ed;	
@@ -823,12 +824,10 @@
 			urb_priv->ed->state |= ED_URB_DEL;
 
 			if (!(urb->transfer_flags & USB_ASYNC_UNLINK)) {
-				DECLARE_WAIT_QUEUE_HEAD (unlink_wakeup); 
 				DECLARE_WAITQUEUE (wait, current);
 				int timeout = OHCI_UNLINK_TIMEOUT;
 
-				add_wait_queue (&unlink_wakeup, &wait);
-				urb_priv->wait = &unlink_wakeup;
+				add_wait_queue(&urb_priv->wait, &wait);
 				spin_unlock_irqrestore(&ohci->ohci_lock, flags);
 
 				/* wait until all TDs are deleted */
@@ -838,7 +837,16 @@
 					set_current_state(TASK_UNINTERRUPTIBLE);
 				}
 				set_current_state(TASK_RUNNING);
-				remove_wait_queue (&unlink_wakeup, &wait); 
+
+				/*
+				 * A waitqueue head is self-locked, but we try
+				 * to interlock with the dl_del_urb() which may
+				 * be doing wake_up() right now, least
+				 * urb->complete poisons over the urb->wait.
+				 */
+				spin_lock_irqsave(&ohci->ohci_lock, flags);
+				remove_wait_queue(&urb_priv->wait, &wait); 
+				spin_unlock_irqrestore(&ohci->ohci_lock, flags);
 				if (urb->status == USB_ST_URB_PENDING) {
 					err ("unlink URB timeout");
 					return -ETIMEDOUT;
@@ -943,18 +951,16 @@
 				warn ("TD leak, %d", cnt);
 
 			} else if (!in_interrupt ()) {
-				DECLARE_WAIT_QUEUE_HEAD (freedev_wakeup); 
 				DECLARE_WAITQUEUE (wait, current);
 				int timeout = OHCI_UNLINK_TIMEOUT;
 
 				/* SF interrupt handler calls dl_del_list */
-				add_wait_queue (&freedev_wakeup, &wait);
-				dev->wait = &freedev_wakeup;
+				add_wait_queue (&dev->wait, &wait);
 				set_current_state(TASK_UNINTERRUPTIBLE);
 				while (timeout && dev->ed_cnt)
 					timeout = schedule_timeout (timeout);
 				set_current_state(TASK_RUNNING);
-				remove_wait_queue (&freedev_wakeup, &wait);
+				remove_wait_queue (&dev->wait, &wait);
 				if (dev->ed_cnt) {
 					err ("free device %d timeout", usb_dev->devnum);
 					return -ETIMEDOUT;
@@ -1560,7 +1566,7 @@
 
 static void dl_del_urb (ohci_t *ohci, struct urb * urb)
 {
-	wait_queue_head_t * wait_head = ((urb_priv_t *)(urb->hcpriv))->wait;
+ 	urb_priv_t * urb_priv = urb->hcpriv;
 
 	urb_rm_priv_locked (urb);
 
@@ -1571,8 +1577,7 @@
 		urb->status = -ENOENT;
 
 		/* unblock sohci_unlink_urb */
-		if (wait_head)
-			wake_up (wait_head);
+		wake_up(&urb_priv->wait);
 	}
 }
 
@@ -1664,13 +1669,8 @@
 			ed->state = ED_NEW;
 			hash_free_ed(ohci, ed);
    	 		/* if all eds are removed wake up sohci_free_dev */
-   	 		if (!--dev->ed_cnt) {
-				wait_queue_head_t *wait_head = dev->wait;
-
-				dev->wait = 0;
-				if (wait_head)
-					wake_up (wait_head);
-			}
+   	 		if (!--dev->ed_cnt)
+				wake_up(&dev->wait);
    	 	} else {
    	 		ed->state &= ~ED_URB_DEL;
 			tdHeadP = dma_to_td (ohci, le32_to_cpup (&ed->hwHeadP) & 0xfffffff0);
diff -urN linux-2.4.28-bk4/drivers/usb/host/usb-ohci.h linux-2.4.28-bk5/drivers/usb/host/usb-ohci.h
--- linux-2.4.28-bk4/drivers/usb/host/usb-ohci.h	2004-04-14 06:05:33.000000000 -0700
+++ linux-2.4.28-bk5/drivers/usb/host/usb-ohci.h	2004-11-24 02:49:32.513995143 -0800
@@ -336,7 +336,7 @@
 	__u16 length;	// number of tds associated with this request
 	__u16 td_cnt;	// number of tds already serviced
 	int   state;
-	wait_queue_head_t * wait;
+	wait_queue_head_t wait;
 	td_t * td[0];	// list pointer to all corresponding TDs associated with this request
 
 } urb_priv_t;
@@ -417,7 +417,7 @@
 	ed_t 	ed[NUM_EDS];
 	dma_addr_t dma;
 	int ed_cnt;
-	wait_queue_head_t * wait;
+	wait_queue_head_t wait;
 };
 
 // #define ohci_to_usb(ohci)	((ohci)->usb)
@@ -626,6 +626,7 @@
 	dev = pci_pool_alloc (hc->dev_cache, mem_flags, &dma);
 	if (dev) {
 		memset (dev, 0, sizeof (*dev));
+		init_waitqueue_head (&dev->wait);
 		dev->dma = dma;
 		offset = ((char *)&dev->ed) - ((char *)dev);
 		for (i = 0; i < NUM_EDS; i++, offset += sizeof dev->ed [0])
diff -urN linux-2.4.28-bk4/fs/binfmt_elf.c linux-2.4.28-bk5/fs/binfmt_elf.c
--- linux-2.4.28-bk4/fs/binfmt_elf.c	2004-11-17 03:54:21.000000000 -0800
+++ linux-2.4.28-bk5/fs/binfmt_elf.c	2004-11-24 02:49:32.514995183 -0800
@@ -79,13 +79,17 @@
 
 #define BAD_ADDR(x)	((unsigned long)(x) > TASK_SIZE)
 
-static void set_brk(unsigned long start, unsigned long end)
+static int set_brk(unsigned long start, unsigned long end)
 {
 	start = ELF_PAGEALIGN(start);
 	end = ELF_PAGEALIGN(end);
-	if (end <= start)
-		return;
-	do_brk(start, end - start);
+	if (end > start) {
+		unsigned long addr = do_brk(start, end - start);
+		if (BAD_ADDR(addr))
+			return addr;
+	}
+	current->mm->start_brk = current->mm->brk = end;
+	return 0;
 }
 
 
@@ -331,6 +335,18 @@
 	    }
 
 	    /*
+	     * Check to see if the section's size will overflow the
+	     * allowed task size. Note that p_filesz must always be
+	     * <= p_memsize so it is only necessary to check p_memsz.
+	     */
+	    k = load_addr + eppnt->p_vaddr;
+	    if (k > TASK_SIZE || eppnt->p_filesz > eppnt->p_memsz ||
+		eppnt->p_memsz > TASK_SIZE || TASK_SIZE - eppnt->p_memsz < k) {
+	        error = -ENOMEM;
+		goto out_close;
+	    }
+
+	    /*
 	     * Find the end of the file mapping for this phdr, and keep
 	     * track of the largest address we see for this.
 	     */
@@ -360,8 +376,11 @@
 	elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);	/* What we have mapped so far */
 
 	/* Map the last of the bss segment */
-	if (last_bss > elf_bss)
-		do_brk(elf_bss, last_bss - elf_bss);
+	if (last_bss > elf_bss) {
+		error = do_brk(elf_bss, last_bss - elf_bss);
+		if (BAD_ADDR(error))
+			goto out_close;
+	}
 
 	*interp_load_addr = load_addr;
 	error = ((unsigned long) interp_elf_ex->e_entry) + load_addr;
@@ -670,7 +689,12 @@
 			/* There was a PT_LOAD segment with p_memsz > p_filesz
 			   before this one. Map anonymous pages, if needed,
 			   and clear the area.  */
-			set_brk (elf_bss + load_bias, elf_brk + load_bias);
+			retval = set_brk (elf_bss + load_bias,
+					  elf_brk + load_bias);
+			if (retval) {
+				send_sig(SIGKILL, current, 0);
+				goto out_free_dentry;
+			}
 			nbyte = ELF_PAGEOFFSET(elf_bss);
 			if (nbyte) {
 				nbyte = ELF_MIN_ALIGN - nbyte;
@@ -716,6 +740,19 @@
 		if (k < start_code) start_code = k;
 		if (start_data < k) start_data = k;
 
+		/*
+		 * Check to see if the section's size will overflow the
+		 * allowed task size. Note that p_filesz must always be
+		 * <= p_memsz so it is only necessary to check p_memsz.
+		 */
+		if (k > TASK_SIZE || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
+		    elf_ppnt->p_memsz > TASK_SIZE ||
+		    TASK_SIZE - elf_ppnt->p_memsz < k) {
+			/* set_brk can never work.  Avoid overflows.  */
+			send_sig(SIGKILL, current, 0);
+			goto out_free_dentry;
+		}
+
 		k = elf_ppnt->p_vaddr + elf_ppnt->p_filesz;
 
 		if (k > elf_bss)
@@ -737,6 +774,18 @@
 	start_data += load_bias;
 	end_data += load_bias;
 
+	/* Calling set_brk effectively mmaps the pages that we need
+	 * for the bss and break sections.  We must do this before
+	 * mapping in the interpreter, to make sure it doesn't wind
+	 * up getting placed where the bss needs to go.
+	 */
+	retval = set_brk(elf_bss, elf_brk);
+	if (retval) {
+		send_sig(SIGKILL, current, 0);
+		goto out_free_dentry;
+	}
+	padzero(elf_bss);
+
 	if (elf_interpreter) {
 		if (interpreter_type == INTERPRETER_AOUT)
 			elf_entry = load_aout_interp(&interp_ex,
@@ -785,13 +834,6 @@
 	current->mm->end_data = end_data;
 	current->mm->start_stack = bprm->p;
 
-	/* Calling set_brk effectively mmaps the pages that we need
-	 * for the bss and break sections
-	 */
-	set_brk(elf_bss, elf_brk);
-
-	padzero(elf_bss);
-
 #if 0
 	printk("(start_brk) %lx\n" , (long) current->mm->start_brk);
 	printk("(end_code) %lx\n" , (long) current->mm->end_code);
diff -urN linux-2.4.28-bk4/fs/intermezzo/cache.c linux-2.4.28-bk5/fs/intermezzo/cache.c
--- linux-2.4.28-bk4/fs/intermezzo/cache.c	2004-11-17 03:54:21.000000000 -0800
+++ linux-2.4.28-bk5/fs/intermezzo/cache.c	2004-11-24 02:49:32.517995305 -0800
@@ -163,6 +163,9 @@
                 cache->cache_sb->s_root->d_fsdata = NULL;
         }
 
+		if (cache->cache_type)
+				PRESTO_FREE(cache->cache_type, strlen(cache->cache_type) + 1 );
+
         PRESTO_FREE(cache, sizeof(struct presto_cache));
 }
 
diff -urN linux-2.4.28-bk4/fs/intermezzo/dcache.c linux-2.4.28-bk5/fs/intermezzo/dcache.c
--- linux-2.4.28-bk4/fs/intermezzo/dcache.c	2002-11-28 15:53:15.000000000 -0800
+++ linux-2.4.28-bk5/fs/intermezzo/dcache.c	2004-11-24 02:49:32.517995305 -0800
@@ -324,6 +324,11 @@
                         dentry, dentry->d_name.len, dentry->d_name.name, 
                         dentry->d_fsdata);
         unlock_kernel();
+
+        filter_setup_dentry_ops(fset->fset_cache->cache_filter,
+                                dentry->d_op, &presto_dentry_ops);
+        dentry->d_op = filter_c2udops(fset->fset_cache->cache_filter);
+
         return error; 
 }
 
diff -urN linux-2.4.28-bk4/fs/intermezzo/dir.c linux-2.4.28-bk5/fs/intermezzo/dir.c
--- linux-2.4.28-bk4/fs/intermezzo/dir.c	2002-11-28 15:53:15.000000000 -0800
+++ linux-2.4.28-bk5/fs/intermezzo/dir.c	2004-11-24 02:49:32.518995345 -0800
@@ -300,10 +300,7 @@
         /* some file systems have no read_inode: set methods here */
         if (dentry->d_inode)
                 presto_set_ops(dentry->d_inode, cache->cache_filter);
-
-        filter_setup_dentry_ops(cache->cache_filter,
-                                dentry->d_op, &presto_dentry_ops);
-        dentry->d_op = filter_c2udops(cache->cache_filter);
+		/* dentry->d_op is now hooked in dcache.c:presto_set_dd */
 
         /* In lookup we will tolerate EROFS return codes from presto_set_dd
          * to placate NFS. EROFS indicates that a fileset was not found but
diff -urN linux-2.4.28-bk4/fs/intermezzo/fileset.c linux-2.4.28-bk5/fs/intermezzo/fileset.c
--- linux-2.4.28-bk4/fs/intermezzo/fileset.c	2002-11-28 15:53:15.000000000 -0800
+++ linux-2.4.28-bk5/fs/intermezzo/fileset.c	2004-11-24 02:49:32.519995385 -0800
@@ -159,7 +159,7 @@
                 CDEBUG(D_INODE, "Error %d\n", error);
         }
 
-        PRESTO_FREE(path, strlen(path));
+        PRESTO_FREE(path, strlen(path)+1);
 
         EXIT;
         return f;
@@ -259,6 +259,7 @@
                 error = -ENOMEM;
                 goto out_free;
         }
+		
         presto_d2d(dentry)->dd_fset = fset;
         list_add(&fset->fset_list, &cache->cache_fset_list);
 
@@ -343,6 +344,7 @@
         dput(fset->fset_dentry);
         mntput(fset->fset_mnt);
 
+		izo_rep_cache_clean(fset);
         PRESTO_FREE(fset->fset_name, strlen(fset->fset_name) + 1);
         PRESTO_FREE(fset->fset_reint_buf, 64 * 1024);
         PRESTO_FREE(fset, sizeof(*fset));
diff -urN linux-2.4.28-bk4/fs/intermezzo/journal_xfs.c linux-2.4.28-bk5/fs/intermezzo/journal_xfs.c
--- linux-2.4.28-bk4/fs/intermezzo/journal_xfs.c	2002-11-28 15:53:15.000000000 -0800
+++ linux-2.4.28-bk5/fs/intermezzo/journal_xfs.c	2004-11-24 02:49:32.519995385 -0800
@@ -58,7 +58,7 @@
         VFS_STATVFS(vfsp, &stat, NULL, rc);
         avail = statp.f_bfree;
 
-        return sbp->sb_fdblocks;; 
+        return sbp->sb_fdblocks;
 #endif
         return 0x0fffffff;
 }
diff -urN linux-2.4.28-bk4/fs/intermezzo/methods.c linux-2.4.28-bk5/fs/intermezzo/methods.c
--- linux-2.4.28-bk4/fs/intermezzo/methods.c	2002-11-28 15:53:15.000000000 -0800
+++ linux-2.4.28-bk5/fs/intermezzo/methods.c	2004-11-24 02:49:32.520995426 -0800
@@ -254,8 +254,8 @@
         if (ops == NULL) {
                 CERROR("prepare to die: unrecognized cache type for Filter\n");
         }
-        return ops;
         FEXIT;
+        return ops;
 }
 
 
diff -urN linux-2.4.28-bk4/fs/intermezzo/psdev.c linux-2.4.28-bk5/fs/intermezzo/psdev.c
--- linux-2.4.28-bk4/fs/intermezzo/psdev.c	2002-11-28 15:53:15.000000000 -0800
+++ linux-2.4.28-bk5/fs/intermezzo/psdev.c	2004-11-24 02:49:32.521995466 -0800
@@ -102,8 +102,7 @@
                 struct list_head *lh;
                 struct upc_req *req;
                 CERROR("WARNING: setpid & processing not empty!\n");
-                lh = &channel->uc_processing;
-                while ( (lh = lh->next) != &channel->uc_processing) {
+		list_for_each(lh, &channel->uc_processing) {
                         req = list_entry(lh, struct upc_req, rq_chain);
                         /* freeing of req and data is done by the sleeper */
                         wake_up(&req->rq_sleep);
@@ -208,8 +207,7 @@
 
         spin_lock(&channel->uc_lock); 
         /* Look for the message on the processing queue. */
-        lh  = &channel->uc_processing;
-        while ( (lh = lh->next) != &channel->uc_processing ) {
+	list_for_each(lh, &channel->uc_processing) {
                 tmp = list_entry(lh, struct upc_req , rq_chain);
                 if (tmp->rq_unique == hdr.unique) {
                         req = tmp;
@@ -340,8 +338,7 @@
         /* Wake up clients so they can return. */
         CDEBUG(D_PSDEV, "Wake up clients sleeping for pending.\n");
         spin_lock(&channel->uc_lock); 
-        lh = &channel->uc_pending;
-        while ( (lh = lh->next) != &channel->uc_pending) {
+	list_for_each(lh, &channel->uc_pending) {
                 req = list_entry(lh, struct upc_req, rq_chain);
 
                 /* Async requests stay around for a new lento */
@@ -354,8 +351,7 @@
         }
 
         CDEBUG(D_PSDEV, "Wake up clients sleeping for processing\n");
-        lh = &channel->uc_processing;
-        while ( (lh = lh->next) != &channel->uc_processing) {
+	list_for_each(lh, &channel->uc_processing) {
                 req = list_entry(lh, struct upc_req, rq_chain);
                 /* freeing of req and data is done by the sleeper */
                 req->rq_flags |= REQ_DEAD; 
@@ -421,7 +417,7 @@
 
         for ( i = 0 ; i < MAX_CHANNEL ; i++ ) {
                 struct upc_channel *channel = &(izo_channels[i]);
-                struct list_head *lh;
+                struct list_head *lh, *next;
 
                 spin_lock(&channel->uc_lock); 
                 if ( ! list_empty(&channel->uc_pending)) { 
@@ -433,12 +429,10 @@
                 if ( ! list_empty(&channel->uc_cache_list)) { 
                         CERROR("Weird, tell Peter: module cleanup and cache listnot empty dev %d\n", i);
                 }
-                lh = channel->uc_pending.next;
-                while ( lh != &channel->uc_pending) {
+		list_for_each_safe(lh, next, &channel->uc_pending) {
                         struct upc_req *req;
 
                         req = list_entry(lh, struct upc_req, rq_chain);
-                        lh = lh->next;
                         if ( req->rq_flags & REQ_ASYNC ) {
                                 list_del(&(req->rq_chain));
                                 CDEBUG(D_UPCALL, "free pending upcall type %d\n",
@@ -450,8 +444,7 @@
                                 wake_up(&req->rq_sleep);
                         }
                 }
-                lh = &channel->uc_processing;
-                while ( (lh = lh->next) != &channel->uc_processing ) {
+		list_for_each(lh, &channel->uc_processing) {
                         struct upc_req *req;
                         req = list_entry(lh, struct upc_req, rq_chain);
                         list_del(&(req->rq_chain));
@@ -564,6 +557,10 @@
         buffer->u_uniq = req->rq_unique;
         buffer->u_async = async;
 
+        /* Remove potential datarace possibility*/
+        if ( async ) 
+                req->rq_flags = REQ_ASYNC;
+
         spin_lock(&channel->uc_lock); 
         /* Append msg to pending queue and poke Lento. */
         list_add(&req->rq_chain, channel->uc_pending.prev);
@@ -576,7 +573,7 @@
 
         if ( async ) {
                 /* req, rq_data are freed in presto_psdev_read for async */
-                req->rq_flags = REQ_ASYNC;
+                /* req->rq_flags = REQ_ASYNC;*/
                 EXIT;
                 return 0;
         }
@@ -647,5 +644,6 @@
 exit_req:
         PRESTO_FREE(req, sizeof(struct upc_req));
 exit_buf:
+        PRESTO_FREE(buffer,*size);
         return error;
 }
diff -urN linux-2.4.28-bk4/fs/intermezzo/replicator.c linux-2.4.28-bk5/fs/intermezzo/replicator.c
--- linux-2.4.28-bk4/fs/intermezzo/replicator.c	2002-11-28 15:53:15.000000000 -0800
+++ linux-2.4.28-bk5/fs/intermezzo/replicator.c	2004-11-24 02:49:32.522995507 -0800
@@ -70,7 +70,7 @@
         return &cache[(RCACHE_MASK & uuid[1])];
 }
 
-static void
+void
 izo_rep_cache_clean(struct presto_file_set *fset)
 {
 	int i;
@@ -80,28 +80,25 @@
         if (fset->fset_clients == NULL)
 		return;
         for (i = 0; i < RCACHE_SIZE; i++) {
-		tmp = bucket = &fset->fset_clients[i];
 
-		tmp = tmp->next;
-                while (tmp != bucket) {
-			struct izo_offset_rec *offrec;
-			tmp = tmp->next;
-			list_del(tmp);
-			offrec = list_entry(tmp, struct izo_offset_rec,
-					    or_list);
-			PRESTO_FREE(offrec, sizeof(struct izo_offset_rec));
+				list_for_each_safe(tmp,bucket,&fset->fset_clients[i])
+				{
+						struct izo_offset_rec *offrec;
+						list_del(tmp);
+						offrec = list_entry(tmp, struct izo_offset_rec,or_list);
+						PRESTO_FREE(offrec, sizeof(struct izo_offset_rec)); 
+				}
 		}
-	}
+		PRESTO_FREE(fset->fset_clients,sizeof(struct list_head) * RCACHE_SIZE);
 }
 
 struct izo_offset_rec *
 izo_rep_cache_find(struct presto_file_set *fset, char *uuid)
 {
-	struct list_head *buck = izo_rep_hash(fset->fset_clients, uuid);
-	struct list_head *tmp = buck;
+	struct list_head *tmp, *buck = izo_rep_hash(fset->fset_clients, uuid);
         struct izo_offset_rec *rec = NULL;
 
-        while ( (tmp = tmp->next) != buck ) {
+	list_for_each(tmp, buck) {
 		rec = list_entry(tmp, struct izo_offset_rec, or_list);
                 if ( memcmp(rec->or_uuid, uuid, sizeof(rec->or_uuid)) == 0 )
 			return rec;
diff -urN linux-2.4.28-bk4/fs/intermezzo/super.c linux-2.4.28-bk5/fs/intermezzo/super.c
--- linux-2.4.28-bk4/fs/intermezzo/super.c	2002-11-28 15:53:15.000000000 -0800
+++ linux-2.4.28-bk5/fs/intermezzo/super.c	2004-11-24 02:49:32.522995507 -0800
@@ -23,8 +23,8 @@
  *  presto's super.c
  */
 
-static char rcsid[] __attribute ((unused)) = "$Id: super.c,v 1.41 2002/10/03 03:50:49 rread Exp $";
-#define INTERMEZZO_VERSION "$Revision: 1.41 $"
+static char rcsid[] __attribute ((unused)) = "$Id: super.c,v 1.42 2003/09/30 15:51:52 sunsetyang Exp $";
+#define INTERMEZZO_VERSION "$Revision: 1.42 $"
 
 #include <stdarg.h>
 
@@ -172,6 +172,7 @@
                 minor = izo_psdev_get_free_channel();
         } else {
                 minor = simple_strtoul(channel, NULL, 0); 
+				PRESTO_FREE(channel, strlen(channel) + 1);
         }
         if (minor < 0 || minor >= MAX_CHANNEL) { 
                 CERROR("all channels in use or channel too large %d\n", 
@@ -287,6 +288,9 @@
         presto_cache_add(cache, sb->s_dev);
         err = izo_prepare_fileset(sb->s_root, fileset); 
 
+        if (fileset)
+                PRESTO_FREE(fileset, strlen(fileset) + 1);
+
         filter_setup_journal_ops(cache->cache_filter, cache->cache_type); 
 
         /* make sure we have our own super operations: sb
diff -urN linux-2.4.28-bk4/fs/intermezzo/vfs.c linux-2.4.28-bk5/fs/intermezzo/vfs.c
--- linux-2.4.28-bk4/fs/intermezzo/vfs.c	2003-06-13 07:51:37.000000000 -0700
+++ linux-2.4.28-bk5/fs/intermezzo/vfs.c	2004-11-24 02:49:32.524995588 -0800
@@ -2194,6 +2194,7 @@
         if ( error && error != -ENOENT ) {
                 EXIT;
                 unlock_kernel();
+                putname(tmp);
                 return error;
         } 
         if (error == -ENOENT)
@@ -2240,7 +2241,7 @@
         fd = get_unused_fd();
         if (fd < 0) {
                 EXIT;
-                goto cleanup_dput;
+                goto exit;
         }
 
         {
@@ -2250,10 +2251,9 @@
                 if (IS_ERR(f)) {
                         put_unused_fd(fd);
                         fd = error;
-                        EXIT;
-                        goto cleanup_dput;
+                } else {
+                        fd_install(fd, f);
                 }
-                fd_install(fd, f);
         }
         /* end of code that might be replaced by open_dentry */
 
@@ -2263,10 +2263,6 @@
         path_release(&nd);
         putname(tmp);
         return fd;
-
-cleanup_dput:
-        putname(&nd);
-        goto exit;
 }
 
 #ifdef CONFIG_FS_EXT_ATTR
diff -urN linux-2.4.28-bk4/include/linux/intermezzo_fs.h linux-2.4.28-bk5/include/linux/intermezzo_fs.h
--- linux-2.4.28-bk4/include/linux/intermezzo_fs.h	2004-11-17 03:54:22.000000000 -0800
+++ linux-2.4.28-bk5/include/linux/intermezzo_fs.h	2004-11-24 02:49:32.573997569 -0800
@@ -651,6 +651,7 @@
 int izo_repstatus(struct presto_file_set *fset, __u64 client_kmlsize, 
                   struct izo_rcvd_rec *lr_client, struct izo_rcvd_rec *lr_server);
 int izo_rep_cache_init(struct presto_file_set *);
+void izo_rep_cache_clean(struct presto_file_set *fset);
 loff_t izo_rcvd_get(struct izo_rcvd_rec *, struct presto_file_set *, char *uuid);
 loff_t izo_rcvd_write(struct presto_file_set *, struct izo_rcvd_rec *);
 loff_t izo_rcvd_upd_remote(struct presto_file_set *fset, char * uuid,  __u64 remote_recno,
@@ -708,10 +709,17 @@
 static inline char *strdup(char *str)
 {
         char *tmp;
-        tmp = kmalloc(strlen(str) + 1, GFP_KERNEL);
-        if (tmp)
-                memcpy(tmp, str, strlen(str) + 1);
-               
+		long int s;
+
+		s=strlen(str) + 1;
+        tmp = kmalloc(s, GFP_KERNEL);
+        if (tmp){
+				  memcpy(tmp, str, s);
+				  presto_kmem_inc(tmp, s);
+		}
+        CDEBUG(D_MALLOC, "kmalloced: %ld at %p (tot %ld).\n",
+               s, tmp, presto_kmemory);
+				  
         return tmp;
 }
 
diff -urN linux-2.4.28-bk4/net/decnet/dn_neigh.c linux-2.4.28-bk5/net/decnet/dn_neigh.c
--- linux-2.4.28-bk4/net/decnet/dn_neigh.c	2004-11-17 03:54:22.000000000 -0800
+++ linux-2.4.28-bk5/net/decnet/dn_neigh.c	2004-11-24 02:49:32.582997933 -0800
@@ -26,6 +26,7 @@
 
 #include <linux/config.h>
 #include <linux/net.h>
+#include <linux/module.h>
 #include <linux/socket.h>
 #include <linux/if_arp.h>
 #include <linux/if_ether.h>
