Whamcloud - gitweb
- bring in akpm's patch management scripts and a first cut at
authorzab <zab>
Sat, 7 Dec 2002 00:21:14 +0000 (00:21 +0000)
committerzab <zab>
Sat, 7 Dec 2002 00:21:14 +0000 (00:21 +0000)
  patch-2.4.18-14 and patch-2.4.18-um against 2.4.18-17.8.0.  the README
  should hopefully make it clear how these are intended to be used.  email
  to follow.

61 files changed:
lustre/kernel_patches/README [new file with mode: 0644]
lustre/kernel_patches/patches/dev_read_only.patch [new file with mode: 0644]
lustre/kernel_patches/patches/exports.patch [new file with mode: 0644]
lustre/kernel_patches/patches/kmem_cache_validate.patch [new file with mode: 0644]
lustre/kernel_patches/patches/lustre_version.patch [new file with mode: 0644]
lustre/kernel_patches/patches/uml_check_get_page.patch [new file with mode: 0644]
lustre/kernel_patches/patches/uml_compile_fixes.patch [new file with mode: 0644]
lustre/kernel_patches/patches/uml_no_panic.patch [new file with mode: 0644]
lustre/kernel_patches/patches/vfs_intent.patch [new file with mode: 0644]
lustre/kernel_patches/pc/dev_read_only.pc [new file with mode: 0644]
lustre/kernel_patches/pc/exports.pc [new file with mode: 0644]
lustre/kernel_patches/pc/kmem_cache_validate.pc [new file with mode: 0644]
lustre/kernel_patches/pc/lustre_version.pc [new file with mode: 0644]
lustre/kernel_patches/pc/uml_check_get_page.pc [new file with mode: 0644]
lustre/kernel_patches/pc/uml_compile_fixes.pc [new file with mode: 0644]
lustre/kernel_patches/pc/uml_no_panic.pc [new file with mode: 0644]
lustre/kernel_patches/pc/vfs_intent.pc [new file with mode: 0644]
lustre/kernel_patches/prepare_tree.sh [new file with mode: 0755]
lustre/kernel_patches/scripts/added-by-patch [new file with mode: 0755]
lustre/kernel_patches/scripts/apatch [new file with mode: 0755]
lustre/kernel_patches/scripts/combine-applied [new file with mode: 0755]
lustre/kernel_patches/scripts/combine-series [new file with mode: 0755]
lustre/kernel_patches/scripts/cvs-take-patch [new file with mode: 0755]
lustre/kernel_patches/scripts/docco.txt [new file with mode: 0644]
lustre/kernel_patches/scripts/export_patch [new file with mode: 0755]
lustre/kernel_patches/scripts/extract_description [new file with mode: 0755]
lustre/kernel_patches/scripts/fpatch [new file with mode: 0755]
lustre/kernel_patches/scripts/import_patch [new file with mode: 0755]
lustre/kernel_patches/scripts/inpatch [new file with mode: 0755]
lustre/kernel_patches/scripts/linus-patch [new file with mode: 0755]
lustre/kernel_patches/scripts/mpatch [new file with mode: 0755]
lustre/kernel_patches/scripts/new-kernel [new file with mode: 0755]
lustre/kernel_patches/scripts/p0-2-p1 [new file with mode: 0755]
lustre/kernel_patches/scripts/p_diff [new file with mode: 0755]
lustre/kernel_patches/scripts/patchdesc [new file with mode: 0755]
lustre/kernel_patches/scripts/patchfns [new file with mode: 0644]
lustre/kernel_patches/scripts/pcpatch [new file with mode: 0755]
lustre/kernel_patches/scripts/poppatch [new file with mode: 0755]
lustre/kernel_patches/scripts/prep-patch [new file with mode: 0755]
lustre/kernel_patches/scripts/pstatus [new file with mode: 0755]
lustre/kernel_patches/scripts/ptkdiff [new file with mode: 0755]
lustre/kernel_patches/scripts/pushpatch [new file with mode: 0755]
lustre/kernel_patches/scripts/refpatch [new file with mode: 0755]
lustre/kernel_patches/scripts/removed-by-patch [new file with mode: 0755]
lustre/kernel_patches/scripts/rename-patch [new file with mode: 0755]
lustre/kernel_patches/scripts/rolled-up-patch [new file with mode: 0755]
lustre/kernel_patches/scripts/rpatch [new file with mode: 0755]
lustre/kernel_patches/scripts/split-patch [new file with mode: 0755]
lustre/kernel_patches/scripts/tag-series [new file with mode: 0755]
lustre/kernel_patches/scripts/toppatch [new file with mode: 0755]
lustre/kernel_patches/scripts/touched-by-patch [new file with mode: 0755]
lustre/kernel_patches/scripts/unitdiff.py [new file with mode: 0755]
lustre/kernel_patches/series/rh-8.0 [new file with mode: 0644]
lustre/kernel_patches/txt/dev_read_only.txt [new file with mode: 0644]
lustre/kernel_patches/txt/exports.txt [new file with mode: 0644]
lustre/kernel_patches/txt/kmem_cache_validate.txt [new file with mode: 0644]
lustre/kernel_patches/txt/lustre_version.txt [new file with mode: 0644]
lustre/kernel_patches/txt/uml_check_get_page.txt [new file with mode: 0644]
lustre/kernel_patches/txt/uml_compile_fixes.txt [new file with mode: 0644]
lustre/kernel_patches/txt/uml_no_panic.txt [new file with mode: 0644]
lustre/kernel_patches/txt/vfs_intent.txt [new file with mode: 0644]

diff --git a/lustre/kernel_patches/README b/lustre/kernel_patches/README
new file mode 100644 (file)
index 0000000..05a04d0
--- /dev/null
@@ -0,0 +1,104 @@
+
+Lustre requires changes to the core kernel before it can be compiled against
+hte core kernel source tree.  We use Andrew Morton's 'patch-scripts' utilties
+to keep the complexity of managing changes across multiple kernel targets down.
+They handle the ordering metadata, application, refreshing, and removal of
+patches  for us.  Please read scripts/docco.txt for a more thorough explanation
+of what 'patch-scripts' do.
+
+We create a thin wrapper around patchscripts with our ./prepare_tree.sh.  It
+exports two environment variables.  PATCHSCRIPTS is a relative path from the
+kernel source tree to the checked-out patchscripts repository.  It is requires
+for patchscripts to operate on data outside the kernel source tree.  It also
+puts the absolute path to the scripts/ directory at the front of PATH.
+Finally, it creates a 'series' link from the kernel tree back to the proper
+series file for that kernel tree.  More on that below.
+
+prepare_tree.sh and the patch-scripts commands are the only interface we should
+use on a daily basis.  We should never have to manage the patches by hand.
+This will save us heart-ache once we're good with the tools.  I promise.
+
+Data to be aware of:
+
+patches/
+       contains all the patch files themselves.  We should have a patch per 
+       functional change.  
+
+series/
+       the text files that patch-utils use to define the ordering of patches
+       that are applied to a tree.  We have a series file for each kernel
+       tree variant that requires wildly different patches.  (architecture
+       differences, stock vs. redhat, etc) 
+
+pc/
+       control files for patch-utils.  These are per tree and should never
+       be in cvs.
+
+txt/
+       text descriptions of the patches.  Nice, but not functionally required.
+
+First, before anything happens, you need to prep a tree for use with
+patch-utils.  This means putting a series link in the file and setting the
+environment variable:
+
+       $ eval `./prepare_tree.sh -t /tmp/kernels/linux-2.4.18 -r stock-2.4`
+
+prepare-tree.sh is careful to output variable assignments to stdout and
+everything else to stderr so the eval won't go awry.  It also is clever about
+resolving the series name, so tab-completed relative paths to the series files
+can be used with -r.  (it assumes that series/ is under where prepare_tree.sh
+was executed from).  The series link that is created from the tree back into
+the cvs repository is created by force.  Don't re-run the command with a
+different role.  (this should probably be fixed)
+
+With this in place, the shell that did the eval is ready to wield patch-utils.
+
+] To apply all the patches to a given tree:
+
+       $ eval `./prepare_tree.sh -t /tmp/kernels/linux-2.4.18 -r stock-2.4`
+       $ cd /tmp/kernels/linux-2.4.18
+       $ pushpatch 100000
+               ( the huge number just serves to iterate through the patches )
+
+] To refresh the patches against a newer kernel that the series applies to.
+
+Say the series file 'rh-8.0-dev' corresponds to a CFS policy of tracking the
+most recent red hat 8.0 distro kernel.   It used to be 2.4.18-14, say, and RH
+has now released RH 2.4.18-17.8.0 and CFS has decided to move to it.  We
+want to update the patches in cvs HEAD to be against 2.4.18-17.8.0
+
+       $ eval `./prepare_tree.sh -t /tmp/linux-2.4.18-17.8.0 -r rh-8.0-dev`
+       $ cd /tmp/linux-2.4.18-17.8.0
+       $ for a in $NUM_PATCHES_HAVE ; do
+               pushpatch;
+               refpatch;
+         done
+
+] To add a new series 
+
+Simply add a new empty file to the series/ directory, choosing a descriptive
+name for the series.
+
+] To add a patch into a series
+
+Ideally a patch can be added to the end of the series.  This is most easily
+done with patch-utils import_patch.  After the patch is imported it still needs
+to be applied and refreshed with 'pushpatch' and 'refpatch'.  ___remember to
+cvs add the patch with -ko___ so that tags in the context of the diff aren't
+change by CVS, rendering the patch unusable.
+
+It is considered valuable to have a common HEAD which can be checked out to
+patch a kernel and build lustre across lots of targets.  This creates some
+friction in the desire to keep a single canonical set of patches in CVS.  We
+solve this with the patch-utils scripts by having well-named patches that are
+bound to the different series.  Say alpha and ia64 kernel trees both need a
+common lustre patch.  Ideally they'd both have our-funcionality.patch in their
+series, but perhaps the code path we want to alter is different in the trees
+and not in the architecture-dependant part of the kernel.  For this we'd want
+our-functionality-ia64.patch in the ia64 series file, and
+our-functionality-alpha.patch in the alpha.  This split becomes irritating to
+manage as shared changes want to be pushed to all the patches.  This will be a
+pain as long as the kernel's we're receiving don't share revision control
+somehow.  At least the patch utils make it relatively painless to 'pushpatch'
+the source patch, clean up rejects, test, and 'refpatch' to generate the new
+patch for that series.
diff --git a/lustre/kernel_patches/patches/dev_read_only.patch b/lustre/kernel_patches/patches/dev_read_only.patch
new file mode 100644 (file)
index 0000000..9ff075e
--- /dev/null
@@ -0,0 +1,77 @@
+
+
+
+ 0 files changed
+
+--- linux-2.4.18-17.8.0/drivers/block/blkpg.c~dev_read_only    2002-12-06 14:52:29.000000000 -0800
++++ linux-2.4.18-17.8.0-zab/drivers/block/blkpg.c      2002-12-06 14:52:29.000000000 -0800
+@@ -297,3 +297,38 @@ int blk_ioctl(kdev_t dev, unsigned int c
+ }
+ EXPORT_SYMBOL(blk_ioctl);
++
++#define NUM_DEV_NO_WRITE 16
++static int dev_no_write[NUM_DEV_NO_WRITE];
++
++/*
++ * Debug code for turning block devices "read-only" (will discard writes
++ * silently).  This is for filesystem crash/recovery testing.
++ */
++void dev_set_rdonly(kdev_t dev, int no_write)
++{
++      if (dev) {
++              printk(KERN_WARNING "Turning device %s read-only\n",
++                     bdevname(dev));
++              dev_no_write[no_write] = 0xdead0000 + dev;
++      }
++}
++
++int dev_check_rdonly(kdev_t dev) {
++      int i;
++
++      for (i = 0; i < NUM_DEV_NO_WRITE; i++) {
++              if ((dev_no_write[i] & 0xffff0000) == 0xdead0000 &&
++                  dev == (dev_no_write[i] & 0xffff))
++                      return 1;
++      }
++      return 0;
++}
++
++void dev_clear_rdonly(int no_write) {
++      dev_no_write[no_write] = 0;
++}
++
++EXPORT_SYMBOL(dev_set_rdonly);
++EXPORT_SYMBOL(dev_check_rdonly);
++EXPORT_SYMBOL(dev_clear_rdonly);
+--- linux-2.4.18-17.8.0/drivers/block/loop.c~dev_read_only     2002-12-06 14:52:29.000000000 -0800
++++ linux-2.4.18-17.8.0-zab/drivers/block/loop.c       2002-12-06 14:52:29.000000000 -0800
+@@ -491,6 +491,11 @@ static int loop_make_request(request_que
+       spin_unlock_irq(&lo->lo_lock);
+       if (rw == WRITE) {
++#ifdef CONFIG_DEV_RDONLY
++              if (dev_check_rdonly(rbh->b_rdev))
++                      goto err;
++#endif
++
+               if (lo->lo_flags & LO_FLAGS_READ_ONLY)
+                       goto err;
+       } else if (rw == READA) {
+--- linux-2.4.18-17.8.0/drivers/ide/ide-disk.c~dev_read_only   2002-12-06 14:52:29.000000000 -0800
++++ linux-2.4.18-17.8.0-zab/drivers/ide/ide-disk.c     2002-12-06 14:52:29.000000000 -0800
+@@ -557,6 +557,12 @@ static ide_startstop_t lba_48_rw_disk (i
+  */
+ static ide_startstop_t do_rw_disk (ide_drive_t *drive, struct request *rq, unsigned long block)
+ {
++#ifdef CONFIG_DEV_RDONLY
++      if (rq->cmd == WRITE && dev_check_rdonly(rq->rq_dev)) {
++              ide_end_request(1, HWGROUP(drive));
++              return ide_stopped;
++      }
++#endif
+       if (IDE_CONTROL_REG)
+               OUT_BYTE(drive->ctl,IDE_CONTROL_REG);
+
+_
diff --git a/lustre/kernel_patches/patches/exports.patch b/lustre/kernel_patches/patches/exports.patch
new file mode 100644 (file)
index 0000000..cdf72f0
--- /dev/null
@@ -0,0 +1,53 @@
+
+
+
+ 0 files changed
+
+--- linux-2.4.18-17.8.0/fs/ext3/Makefile~exports       2002-12-06 14:52:29.000000000 -0800
++++ linux-2.4.18-17.8.0-zab/fs/ext3/Makefile   2002-12-06 14:52:29.000000000 -0800
+@@ -9,6 +9,8 @@
+ O_TARGET := ext3.o
++export-objs :=        super.o
++
+ obj-y    := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
+               ioctl.o namei.o super.o symlink.o
+ obj-m    := $(O_TARGET)
+--- linux-2.4.18-17.8.0/fs/ext3/super.c~exports        2002-12-06 14:52:29.000000000 -0800
++++ linux-2.4.18-17.8.0-zab/fs/ext3/super.c    2002-12-06 14:52:29.000000000 -0800
+@@ -1746,7 +1746,7 @@ static void __exit exit_ext3_fs(void)
+       unregister_filesystem(&ext3_fs_type);
+ }
+-EXPORT_NO_SYMBOLS;
++EXPORT_SYMBOL(ext3_bread);
+ MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
+ MODULE_DESCRIPTION("Second Extended Filesystem with journaling extensions");
+--- linux-2.4.18-17.8.0/include/linux/fs.h~exports     2002-12-06 14:52:29.000000000 -0800
++++ linux-2.4.18-17.8.0-zab/include/linux/fs.h 2002-12-06 14:52:29.000000000 -0800
+@@ -1046,6 +1046,7 @@ extern int unregister_filesystem(struct 
+ extern struct vfsmount *kern_mount(struct file_system_type *);
+ extern int may_umount(struct vfsmount *);
+ extern long do_mount(char *, char *, char *, unsigned long, void *);
++struct vfsmount *do_kern_mount(const char *type, int flags, char *name, void *data);
+ extern void umount_tree(struct vfsmount *);
+ #define kern_umount mntput
+--- linux-2.4.18-17.8.0/kernel/ksyms.c~exports 2002-12-06 14:52:29.000000000 -0800
++++ linux-2.4.18-17.8.0-zab/kernel/ksyms.c     2002-12-06 14:52:29.000000000 -0800
+@@ -306,6 +306,11 @@ EXPORT_SYMBOL_GPL(buffermem_pages);
+ EXPORT_SYMBOL_GPL(nr_free_pages);
+ EXPORT_SYMBOL_GPL(page_cache_size);
++/* lustre */
++EXPORT_SYMBOL(panic_notifier_list);
++EXPORT_SYMBOL(pagecache_lock_cacheline);
++EXPORT_SYMBOL(do_kern_mount);
++
+ /* for stackable file systems (lofs, wrapfs, cryptfs, etc.) */
+ EXPORT_SYMBOL(default_llseek);
+ EXPORT_SYMBOL(dentry_open);
+
+_
diff --git a/lustre/kernel_patches/patches/kmem_cache_validate.patch b/lustre/kernel_patches/patches/kmem_cache_validate.patch
new file mode 100644 (file)
index 0000000..52880d8
--- /dev/null
@@ -0,0 +1,119 @@
+
+
+
+ 0 files changed
+
+--- linux-2.4.18-17.8.0/arch/i386/mm/init.c~kmem_cache_validate        2002-12-06 14:52:30.000000000 -0800
++++ linux-2.4.18-17.8.0-zab/arch/i386/mm/init.c        2002-12-06 14:52:30.000000000 -0800
+@@ -43,6 +43,12 @@ unsigned long highstart_pfn, highend_pfn
+ static unsigned long totalram_pages;
+ static unsigned long totalhigh_pages;
++struct page *check_get_page(unsigned long kaddr)
++{
++#warning FIXME: Lustre team, is this solid?
++      return virt_to_page(kaddr);
++}
++
+ int do_check_pgt_cache(int low, int high)
+ {
+       int freed = 0;
+--- linux-2.4.18-17.8.0/arch/ia64/mm/init.c~kmem_cache_validate        2002-12-06 14:52:30.000000000 -0800
++++ linux-2.4.18-17.8.0-zab/arch/ia64/mm/init.c        2002-12-06 14:52:30.000000000 -0800
+@@ -37,6 +37,12 @@ unsigned long MAX_DMA_ADDRESS = PAGE_OFF
+ static unsigned long totalram_pages;
++struct page *check_get_page(unsigned long kaddr)
++{
++#warning FIXME: Lustre team, is this solid?
++      return virt_to_page(kaddr);
++}
++
+ int
+ do_check_pgt_cache (int low, int high)
+ {
+--- linux-2.4.18-17.8.0/include/linux/slab.h~kmem_cache_validate       2002-12-06 14:52:30.000000000 -0800
++++ linux-2.4.18-17.8.0-zab/include/linux/slab.h       2002-12-06 14:52:30.000000000 -0800
+@@ -57,6 +57,7 @@ extern int kmem_cache_destroy(kmem_cache
+ extern int kmem_cache_shrink(kmem_cache_t *);
+ extern void *kmem_cache_alloc(kmem_cache_t *, int);
+ extern void kmem_cache_free(kmem_cache_t *, void *);
++extern int kmem_cache_validate(kmem_cache_t *cachep, void *objp);
+ extern void *kmalloc(size_t, int);
+ extern void kfree(const void *);
+--- linux-2.4.18-17.8.0/kernel/ksyms.c~kmem_cache_validate     2002-12-06 14:52:30.000000000 -0800
++++ linux-2.4.18-17.8.0-zab/kernel/ksyms.c     2002-12-06 14:52:30.000000000 -0800
+@@ -119,6 +119,7 @@ EXPORT_SYMBOL(kmem_cache_destroy);
+ EXPORT_SYMBOL(kmem_cache_shrink);
+ EXPORT_SYMBOL(kmem_cache_alloc);
+ EXPORT_SYMBOL(kmem_cache_free);
++EXPORT_SYMBOL(kmem_cache_validate);
+ EXPORT_SYMBOL(kmalloc);
+ EXPORT_SYMBOL(kfree);
+ EXPORT_SYMBOL(vfree);
+--- linux-2.4.18-17.8.0/mm/slab.c~kmem_cache_validate  2002-12-06 14:52:30.000000000 -0800
++++ linux-2.4.18-17.8.0-zab/mm/slab.c  2002-12-06 14:52:30.000000000 -0800
+@@ -1208,6 +1208,59 @@ failed:
+  * Called with the cache-lock held.
+  */
++extern struct page *check_get_page(unsigned long kaddr);
++struct page *page_mem_map(struct page *page);
++static int kmem_check_cache_obj (kmem_cache_t * cachep,
++                               slab_t *slabp, void * objp)
++{
++      int i;
++      unsigned int objnr;
++
++#if DEBUG
++      if (cachep->flags & SLAB_RED_ZONE) {
++              objp -= BYTES_PER_WORD;
++              if ( *(unsigned long *)objp != RED_MAGIC2)
++                      /* Either write before start, or a double free. */
++                      return 0;
++              if (*(unsigned long *)(objp+cachep->objsize -
++                              BYTES_PER_WORD) != RED_MAGIC2)
++                      /* Either write past end, or a double free. */
++                      return 0;
++      }
++#endif
++
++      objnr = (objp-slabp->s_mem)/cachep->objsize;
++      if (objnr >= cachep->num)
++              return 0;
++      if (objp != slabp->s_mem + objnr*cachep->objsize)
++              return 0;
++
++      /* Check slab's freelist to see if this obj is there. */
++      for (i = slabp->free; i != BUFCTL_END; i = slab_bufctl(slabp)[i]) {
++              if (i == objnr)
++                      return 0;
++      }
++      return 1;
++}
++
++
++int kmem_cache_validate(kmem_cache_t *cachep, void *objp)
++{
++      struct page *page = check_get_page((unsigned long)objp);
++
++      if (!VALID_PAGE(page))
++              return 0;
++
++      if (!PageSlab(page))
++              return 0;
++
++      /* XXX check for freed slab objects ? */
++      if (!kmem_check_cache_obj(cachep, GET_PAGE_SLAB(page), objp))
++              return 0;
++
++      return (cachep == GET_PAGE_CACHE(page));
++}
++
+ #if DEBUG
+ static int kmem_extra_free_checks (kmem_cache_t * cachep,
+                       slab_t *slabp, void * objp)
+
+_
diff --git a/lustre/kernel_patches/patches/lustre_version.patch b/lustre/kernel_patches/patches/lustre_version.patch
new file mode 100644 (file)
index 0000000..6fb5ce2
--- /dev/null
@@ -0,0 +1,11 @@
+
+
+
+ 0 files changed
+
+--- /dev/null  2002-08-30 16:31:37.000000000 -0700
++++ linux-2.4.18-17.8.0-zab/include/linux/lustre_version.h     2002-12-06 14:52:30.000000000 -0800
+@@ -0,0 +1 @@
++#define LUSTRE_KERNEL_VERSION 4
+
+_
diff --git a/lustre/kernel_patches/patches/uml_check_get_page.patch b/lustre/kernel_patches/patches/uml_check_get_page.patch
new file mode 100644 (file)
index 0000000..fafdf90
--- /dev/null
@@ -0,0 +1,31 @@
+
+
+
+ 0 files changed
+
+--- linux-2.4.18-17.8.0/arch/um/kernel/mem.c~uml_check_get_page        2002-12-06 14:52:30.000000000 -0800
++++ linux-2.4.18-17.8.0-zab/arch/um/kernel/mem.c       2002-12-06 14:52:30.000000000 -0800
+@@ -529,6 +529,21 @@ struct page *pte_mem_map(pte_t pte)
+       return(phys_mem_map(pte_val(pte)));
+ }
++struct page *check_get_page(unsigned long kaddr)
++{
++      struct page *page;
++      struct mem_region *mr;
++      unsigned long phys = __pa(kaddr);
++      unsigned int n = phys_region_index(phys);
++
++      if (regions[n] == NULL)
++                return NULL;
++
++      mr = regions[n];
++      page = (struct page *) mr->mem_map;
++      return page + ((phys_addr(phys)) >> PAGE_SHIFT);
++}
++
+ struct mem_region *page_region(struct page *page, int *index_out)
+ {
+       int i;
+
+_
diff --git a/lustre/kernel_patches/patches/uml_compile_fixes.patch b/lustre/kernel_patches/patches/uml_compile_fixes.patch
new file mode 100644 (file)
index 0000000..815bd92
--- /dev/null
@@ -0,0 +1,18 @@
+
+
+
+ 0 files changed
+
+--- linux-2.4.18-17.8.0/include/asm-um/pgtable.h~uml_compile_fixes     2002-12-06 15:46:21.000000000 -0800
++++ linux-2.4.18-17.8.0-zab/include/asm-um/pgtable.h   2002-12-06 15:46:21.000000000 -0800
+@@ -200,7 +200,7 @@ static inline void pgd_clear(pgd_t * pgd
+  * called on a highmem page.
+  */
+-#define page_address(page) ({ if (!(page)->virtual) BUG(); (page)->virtual; })
++//#define page_address(page) ({ if (!(page)->virtual) BUG(); (page)->virtual; })
+ #define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))
+ extern struct page *pte_mem_map(pte_t pte);
+
+_
diff --git a/lustre/kernel_patches/patches/uml_no_panic.patch b/lustre/kernel_patches/patches/uml_no_panic.patch
new file mode 100644 (file)
index 0000000..b0c305b
--- /dev/null
@@ -0,0 +1,31 @@
+
+
+
+ 0 files changed
+
+--- linux-2.4.18-17.8.0/arch/um/kernel/mem.c~uml_no_panic      2002-12-06 14:52:30.000000000 -0800
++++ linux-2.4.18-17.8.0-zab/arch/um/kernel/mem.c       2002-12-06 14:52:30.000000000 -0800
+@@ -559,7 +559,9 @@ struct mem_region *page_region(struct pa
+                       return(region);
+               }
+       }
+-      panic("No region found for page");
++//    panic("No region found for page");
++      printk(KERN_ERR "no region foudn for page %p\n, returning NULL\n", 
++                      page);
+       return(NULL);
+ }
+@@ -581,7 +583,9 @@ unsigned long region_pa(void *virt)
+                  (addr <= region->start + region->len))
+                       return(mk_phys(addr - region->start, i));
+       }
+-      panic("region_pa : no region for virtual address");
++      //panic("region_pa : no region for virtual address");
++      printk(KERN_ERR "no region for virtual address %lu, return pa 0\n",
++                      addr);
+       return(0);
+ }
+
+_
diff --git a/lustre/kernel_patches/patches/vfs_intent.patch b/lustre/kernel_patches/patches/vfs_intent.patch
new file mode 100644 (file)
index 0000000..4bba678
--- /dev/null
@@ -0,0 +1,1157 @@
+
+
+
+ 0 files changed
+
+--- linux-2.4.18-17.8.0/fs/dcache.c~vfs_intent 2002-12-06 14:52:31.000000000 -0800
++++ linux-2.4.18-17.8.0-zab/fs/dcache.c        2002-12-06 14:52:31.000000000 -0800
+@@ -150,6 +150,8 @@ repeat:
+ unhash_it:
+       list_del_init(&dentry->d_hash);
++
++
+ kill_it: {
+               struct dentry *parent;
+               list_del(&dentry->d_child);
+@@ -645,6 +647,7 @@ struct dentry * d_alloc(struct dentry * 
+       dentry->d_fsdata = NULL;
+       dentry->d_extra_attributes = NULL;
+       dentry->d_mounted = 0;
++      dentry->d_it = NULL;
+       INIT_LIST_HEAD(&dentry->d_hash);
+       INIT_LIST_HEAD(&dentry->d_lru);
+       INIT_LIST_HEAD(&dentry->d_subdirs);
+--- linux-2.4.18-17.8.0/fs/namei.c~vfs_intent  2002-12-06 14:52:31.000000000 -0800
++++ linux-2.4.18-17.8.0-zab/fs/namei.c 2002-12-06 14:52:31.000000000 -0800
+@@ -1,3 +1,6 @@
++
++
++
+ /*
+  *  linux/fs/namei.c
+  *
+@@ -94,6 +97,14 @@
+  * XEmacs seems to be relying on it...
+  */
++void intent_release(struct dentry *de, struct lookup_intent *it)
++{
++      if (it && de->d_op && de->d_op->d_intent_release)
++              de->d_op->d_intent_release(de, it);
++
++}
++
++
+ /* In order to reduce some races, while at the same time doing additional
+  * checking and hopefully speeding things up, we copy filenames to the
+  * kernel data space before using them..
+@@ -260,10 +271,19 @@ void path_release(struct nameidata *nd)
+  * Internal lookup() using the new generic dcache.
+  * SMP-safe
+  */
+-static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, int flags)
++static struct dentry *cached_lookup(struct dentry *parent, struct qstr *name,
++                                  int flags, struct lookup_intent *it)
+ {
+       struct dentry * dentry = d_lookup(parent, name);
++      if (dentry && dentry->d_op && dentry->d_op->d_revalidate2) {
++              if (!dentry->d_op->d_revalidate2(dentry, flags, it) &&
++                  !d_invalidate(dentry)) {
++                      dput(dentry);
++                      dentry = NULL;
++              }
++              return dentry;
++      } else
+       if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
+               if (!dentry->d_op->d_revalidate(dentry, flags) && !d_invalidate(dentry)) {
+                       dput(dentry);
+@@ -281,7 +301,8 @@ static struct dentry * cached_lookup(str
+  * make sure that nobody added the entry to the dcache in the meantime..
+  * SMP-safe
+  */
+-static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, int flags)
++static struct dentry *real_lookup(struct dentry *parent, struct qstr *name,
++                                int flags, struct lookup_intent *it)
+ {
+       struct dentry * result;
+       struct inode *dir = parent->d_inode;
+@@ -300,6 +321,9 @@ static struct dentry * real_lookup(struc
+               result = ERR_PTR(-ENOMEM);
+               if (dentry) {
+                       lock_kernel();
++                      if (dir->i_op->lookup2)
++                              result = dir->i_op->lookup2(dir, dentry, it);
++                      else
+                       result = dir->i_op->lookup(dir, dentry);
+                       unlock_kernel();
+                       if (result)
+@@ -321,6 +345,12 @@ static struct dentry * real_lookup(struc
+                       dput(result);
+                       result = ERR_PTR(-ENOENT);
+               }
++      } else if (result->d_op && result->d_op->d_revalidate2) {
++              if (!result->d_op->d_revalidate2(result, flags, it) &&
++                  !d_invalidate(result)) {
++                      dput(result);
++                      result = ERR_PTR(-ENOENT);
++              }
+       }
+       return result;
+ }
+@@ -334,7 +364,8 @@ int max_recursive_link = 5;
+  * Without that kind of total limit, nasty chains of consecutive
+  * symlinks can cause almost arbitrarily long lookups. 
+  */
+-static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd)
++static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd, 
++                                 struct lookup_intent *it)
+ {
+       int err;
+       if (current->link_count >= max_recursive_link)
+@@ -348,10 +379,14 @@ static inline int do_follow_link(struct 
+       current->link_count++;
+       current->total_link_count++;
+       UPDATE_ATIME(dentry->d_inode);
+-      err = dentry->d_inode->i_op->follow_link(dentry, nd);
++        if (dentry->d_inode->i_op->follow_link2)
++                err = dentry->d_inode->i_op->follow_link2(dentry, nd, it);
++        else 
++                err = dentry->d_inode->i_op->follow_link(dentry, nd);
+       current->link_count--;
+       return err;
+ loop:
++        intent_release(dentry, it);
+       path_release(nd);
+       return -ELOOP;
+ }
+@@ -449,7 +484,8 @@ static inline void follow_dotdot(struct 
+  *
+  * We expect 'base' to be positive and a directory.
+  */
+-int link_path_walk(const char * name, struct nameidata *nd)
++int link_path_walk_it(const char *name, struct nameidata *nd,
++                    struct lookup_intent *it)
+ {
+       struct dentry *dentry;
+       struct inode *inode;
+@@ -526,12 +562,12 @@ int link_path_walk(const char * name, st
+                               break;
+               }
+               /* This does the actual lookups.. */
+-              dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
++              dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
+               if (!dentry) {
+                       err = -EWOULDBLOCKIO;
+                       if (atomic)
+                               break;
+-                      dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
++                      dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
+                       err = PTR_ERR(dentry);
+                       if (IS_ERR(dentry))
+                               break;
+@@ -548,8 +584,8 @@ int link_path_walk(const char * name, st
+               if (!inode->i_op)
+                       goto out_dput;
+-              if (inode->i_op->follow_link) {
+-                      err = do_follow_link(dentry, nd);
++              if (inode->i_op->follow_link || inode->i_op->follow_link2) {
++                      err = do_follow_link(dentry, nd, it);
+                       dput(dentry);
+                       if (err)
+                               goto return_err;
+@@ -565,7 +601,7 @@ int link_path_walk(const char * name, st
+                       nd->dentry = dentry;
+               }
+               err = -ENOTDIR; 
+-              if (!inode->i_op->lookup)
++              if (!inode->i_op->lookup && !inode->i_op->lookup2)
+                       break;
+               continue;
+               /* here ends the main loop */
+@@ -592,12 +628,12 @@ last_component:
+                       if (err < 0)
+                               break;
+               }
+-              dentry = cached_lookup(nd->dentry, &this, 0);
++              dentry = cached_lookup(nd->dentry, &this, 0, it);
+               if (!dentry) {
+                       err = -EWOULDBLOCKIO;
+                       if (atomic)
+                               break;
+-                      dentry = real_lookup(nd->dentry, &this, 0);
++                      dentry = real_lookup(nd->dentry, &this, 0, it);
+                       err = PTR_ERR(dentry);
+                       if (IS_ERR(dentry))
+                               break;
+@@ -606,8 +642,10 @@ last_component:
+                       ;
+               inode = dentry->d_inode;
+               if ((lookup_flags & LOOKUP_FOLLOW)
+-                  && inode && inode->i_op && inode->i_op->follow_link) {
+-                      err = do_follow_link(dentry, nd);
++                  && inode && inode->i_op && 
++                    (inode->i_op->follow_link || 
++                     inode->i_op->follow_link2)) {
++                      err = do_follow_link(dentry, nd, it);
+                       dput(dentry);
+                       if (err)
+                               goto return_err;
+@@ -621,7 +659,8 @@ last_component:
+                       goto no_inode;
+               if (lookup_flags & LOOKUP_DIRECTORY) {
+                       err = -ENOTDIR; 
+-                      if (!inode->i_op || !inode->i_op->lookup)
++                      if (!inode->i_op || (!inode->i_op->lookup &&
++                                           !inode->i_op->lookup2))
+                               break;
+               }
+               goto return_base;
+@@ -663,10 +702,21 @@ return_err:
+       return err;
+ }
++int link_path_walk(const char * name, struct nameidata *nd)
++{
++      return link_path_walk_it(name, nd, NULL);
++}
++
++int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it)
++{
++      current->total_link_count = 0;
++      return link_path_walk_it(name, nd, it);
++}
++
+ int path_walk(const char * name, struct nameidata *nd)
+ {
+       current->total_link_count = 0;
+-      return link_path_walk(name, nd);
++      return link_path_walk_it(name, nd, NULL);
+ }
+ /* SMP-safe */
+@@ -751,6 +801,17 @@ walk_init_root(const char *name, struct 
+ }
+ /* SMP-safe */
++int path_lookup_it(const char *path, unsigned flags, struct nameidata *nd,
++                 struct lookup_intent *it)
++{
++      int error = 0;
++      if (path_init(path, flags, nd))
++              error = path_walk_it(path, nd, it);
++      return error;
++}
++
++
++/* SMP-safe */
+ int path_lookup(const char *path, unsigned flags, struct nameidata *nd)
+ {
+       int error = 0;
+@@ -779,7 +840,8 @@ int path_init(const char *name, unsigned
+  * needs parent already locked. Doesn't follow mounts.
+  * SMP-safe.
+  */
+-struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
++struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base,
++                             struct lookup_intent *it)
+ {
+       struct dentry * dentry;
+       struct inode *inode;
+@@ -802,13 +864,16 @@ struct dentry * lookup_hash(struct qstr 
+                       goto out;
+       }
+-      dentry = cached_lookup(base, name, 0);
++      dentry = cached_lookup(base, name, 0, it);
+       if (!dentry) {
+               struct dentry *new = d_alloc(base, name);
+               dentry = ERR_PTR(-ENOMEM);
+               if (!new)
+                       goto out;
+               lock_kernel();
++              if (inode->i_op->lookup2)
++                      dentry = inode->i_op->lookup2(inode, new, it);
++              else
+               dentry = inode->i_op->lookup(inode, new);
+               unlock_kernel();
+               if (!dentry)
+@@ -820,6 +885,12 @@ out:
+       return dentry;
+ }
++struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
++{
++      return lookup_hash_it(name, base, NULL);
++}
++
++
+ /* SMP-safe */
+ struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
+ {
+@@ -841,7 +912,7 @@ struct dentry * lookup_one_len(const cha
+       }
+       this.hash = end_name_hash(hash);
+-      return lookup_hash(&this, base);
++      return lookup_hash_it(&this, base, NULL);
+ access:
+       return ERR_PTR(-EACCES);
+ }
+@@ -872,6 +943,23 @@ int __user_walk(const char *name, unsign
+       return err;
+ }
++int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd,
++                 struct lookup_intent *it)
++{
++      char *tmp;
++      int err;
++
++      tmp = getname(name);
++      err = PTR_ERR(tmp);
++      if (!IS_ERR(tmp)) {
++              err = 0;
++              if (path_init(tmp, flags, nd))
++                      err = path_walk_it(tmp, nd, it);
++              putname(tmp);
++      }
++      return err;
++}
++
+ /*
+  * It's inline, so penalty for filesystems that don't use sticky bit is
+  * minimal.
+@@ -1010,7 +1098,8 @@ exit_lock:
+  * for symlinks (where the permissions are checked later).
+  * SMP-safe
+  */
+-int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
++int open_namei_it(const char *pathname, int flag, int mode,
++                struct nameidata *nd, struct lookup_intent *it)
+ {
+       int acc_mode, error = 0;
+       struct inode *inode;
+@@ -1024,7 +1113,7 @@ int open_namei(const char * pathname, in
+        * The simplest case - just a plain lookup.
+        */
+       if (!(flag & O_CREAT)) {
+-              error = path_lookup(pathname, lookup_flags(flag), nd);
++              error = path_lookup_it(pathname, lookup_flags(flag), nd, it);
+               if (error)
+                       return error;
+               dentry = nd->dentry;
+@@ -1034,6 +1123,10 @@ int open_namei(const char * pathname, in
+       /*
+        * Create - we need to know the parent.
+        */
++      if (it) {
++              it->it_mode = mode;
++              it->it_op |= IT_CREAT;
++      }
+       error = path_lookup(pathname, LOOKUP_PARENT, nd);
+       if (error)
+               return error;
+@@ -1049,7 +1142,7 @@ int open_namei(const char * pathname, in
+       dir = nd->dentry;
+       down(&dir->d_inode->i_sem);
+-      dentry = lookup_hash(&nd->last, nd->dentry);
++      dentry = lookup_hash_it(&nd->last, nd->dentry, it);
+ do_last:
+       error = PTR_ERR(dentry);
+@@ -1058,6 +1151,7 @@ do_last:
+               goto exit;
+       }
++      it->it_mode = mode;
+       /* Negative dentry, just create the file */
+       if (!dentry->d_inode) {
+               error = vfs_create(dir->d_inode, dentry,
+@@ -1091,7 +1185,8 @@ do_last:
+       error = -ENOENT;
+       if (!dentry->d_inode)
+               goto exit_dput;
+-      if (dentry->d_inode->i_op && dentry->d_inode->i_op->follow_link)
++      if (dentry->d_inode->i_op && (dentry->d_inode->i_op->follow_link || 
++                                      dentry->d_inode->i_op->follow_link2))
+               goto do_link;
+       dput(nd->dentry);
+@@ -1177,8 +1272,10 @@ ok:
+       return 0;
+ exit_dput:
++      intent_release(dentry, it);
+       dput(dentry);
+ exit:
++      intent_release(nd->dentry, it);
+       path_release(nd);
+       return error;
+@@ -1197,7 +1294,12 @@ do_link:
+        * are done. Procfs-like symlinks just set LAST_BIND.
+        */
+       UPDATE_ATIME(dentry->d_inode);
+-      error = dentry->d_inode->i_op->follow_link(dentry, nd);
++        if (dentry->d_inode->i_op->follow_link2) 
++                error = dentry->d_inode->i_op->follow_link2(dentry, nd, it);
++        else 
++                error = dentry->d_inode->i_op->follow_link(dentry, nd);
++      if (error)
++              intent_release(dentry, it);
+       dput(dentry);
+       if (error)
+               return error;
+@@ -1219,13 +1321,20 @@ do_link:
+       }
+       dir = nd->dentry;
+       down(&dir->d_inode->i_sem);
+-      dentry = lookup_hash(&nd->last, nd->dentry);
++      dentry = lookup_hash_it(&nd->last, nd->dentry, it);
+       putname(nd->last.name);
+       goto do_last;
+ }
++int open_namei(const char *pathname, int flag, int mode, struct nameidata *nd)
++{
++      return open_namei_it(pathname, flag, mode, nd, NULL);
++}
++
++
+ /* SMP-safe */
+-static struct dentry *lookup_create(struct nameidata *nd, int is_dir)
++static struct dentry *lookup_create(struct nameidata *nd, int is_dir,
++                                  struct lookup_intent *it)
+ {
+       struct dentry *dentry;
+@@ -1233,7 +1342,7 @@ static struct dentry *lookup_create(stru
+       dentry = ERR_PTR(-EEXIST);
+       if (nd->last_type != LAST_NORM)
+               goto fail;
+-      dentry = lookup_hash(&nd->last, nd->dentry);
++      dentry = lookup_hash_it(&nd->last, nd->dentry, it);
+       if (IS_ERR(dentry))
+               goto fail;
+       if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
+@@ -1279,6 +1388,7 @@ asmlinkage long sys_mknod(const char * f
+       char * tmp;
+       struct dentry * dentry;
+       struct nameidata nd;
++      struct lookup_intent it = { .it_op = IT_MKNOD, .it_mode = mode };
+       if (S_ISDIR(mode))
+               return -EPERM;
+@@ -1289,7 +1399,7 @@ asmlinkage long sys_mknod(const char * f
+       error = path_lookup(tmp, LOOKUP_PARENT, &nd);
+       if (error)
+               goto out;
+-      dentry = lookup_create(&nd, 0);
++      dentry = lookup_create(&nd, 0, &it);
+       error = PTR_ERR(dentry);
+       mode &= ~current->fs->umask;
+@@ -1307,6 +1417,7 @@ asmlinkage long sys_mknod(const char * f
+               default:
+                       error = -EINVAL;
+               }
++              intent_release(dentry, &it);
+               dput(dentry);
+       }
+       up(&nd.dentry->d_inode->i_sem);
+@@ -1347,6 +1458,7 @@ asmlinkage long sys_mkdir(const char * p
+ {
+       int error = 0;
+       char * tmp;
++      struct lookup_intent it = { .it_op = IT_MKDIR, .it_mode = mode };
+       tmp = getname(pathname);
+       error = PTR_ERR(tmp);
+@@ -1357,11 +1469,12 @@ asmlinkage long sys_mkdir(const char * p
+               error = path_lookup(tmp, LOOKUP_PARENT, &nd);
+               if (error)
+                       goto out;
+-              dentry = lookup_create(&nd, 1);
++              dentry = lookup_create(&nd, 1, &it);
+               error = PTR_ERR(dentry);
+               if (!IS_ERR(dentry)) {
+                       error = vfs_mkdir(nd.dentry->d_inode, dentry,
+                                         mode & ~current->fs->umask);
++                      intent_release(dentry, &it);
+                       dput(dentry);
+               }
+               up(&nd.dentry->d_inode->i_sem);
+@@ -1445,6 +1558,7 @@ asmlinkage long sys_rmdir(const char * p
+       char * name;
+       struct dentry *dentry;
+       struct nameidata nd;
++      struct lookup_intent it = { .it_op = IT_RMDIR };
+       name = getname(pathname);
+       if(IS_ERR(name))
+@@ -1466,10 +1580,11 @@ asmlinkage long sys_rmdir(const char * p
+                       goto exit1;
+       }
+       down(&nd.dentry->d_inode->i_sem);
+-      dentry = lookup_hash(&nd.last, nd.dentry);
++      dentry = lookup_hash_it(&nd.last, nd.dentry, &it);
+       error = PTR_ERR(dentry);
+       if (!IS_ERR(dentry)) {
+               error = vfs_rmdir(nd.dentry->d_inode, dentry);
++              intent_release(dentry, &it);
+               dput(dentry);
+       }
+       up(&nd.dentry->d_inode->i_sem);
+@@ -1513,6 +1628,7 @@ asmlinkage long sys_unlink(const char * 
+       char * name;
+       struct dentry *dentry;
+       struct nameidata nd;
++      struct lookup_intent it = { .it_op = IT_UNLINK };
+       name = getname(pathname);
+       if(IS_ERR(name))
+@@ -1525,7 +1641,7 @@ asmlinkage long sys_unlink(const char * 
+       if (nd.last_type != LAST_NORM)
+               goto exit1;
+       down(&nd.dentry->d_inode->i_sem);
+-      dentry = lookup_hash(&nd.last, nd.dentry);
++      dentry = lookup_hash_it(&nd.last, nd.dentry, &it);
+       error = PTR_ERR(dentry);
+       if (!IS_ERR(dentry)) {
+               /* Why not before? Because we want correct error value */
+@@ -1533,6 +1649,7 @@ asmlinkage long sys_unlink(const char * 
+                       goto slashes;
+               error = vfs_unlink(nd.dentry->d_inode, dentry);
+       exit2:
++              intent_release(dentry, &it);
+               dput(dentry);
+       }
+       up(&nd.dentry->d_inode->i_sem);
+@@ -1579,6 +1696,7 @@ asmlinkage long sys_symlink(const char *
+       int error = 0;
+       char * from;
+       char * to;
++      struct lookup_intent it = { .it_op = IT_SYMLINK };
+       from = getname(oldname);
+       if(IS_ERR(from))
+@@ -1592,10 +1710,12 @@ asmlinkage long sys_symlink(const char *
+               error = path_lookup(to, LOOKUP_PARENT, &nd);
+               if (error)
+                       goto out;
+-              dentry = lookup_create(&nd, 0);
++              it.it_data = from;
++              dentry = lookup_create(&nd, 0, &it);
+               error = PTR_ERR(dentry);
+               if (!IS_ERR(dentry)) {
+                       error = vfs_symlink(nd.dentry->d_inode, dentry, from);
++                      intent_release(dentry, &it);
+                       dput(dentry);
+               }
+               up(&nd.dentry->d_inode->i_sem);
+@@ -1660,6 +1780,7 @@ asmlinkage long sys_link(const char * ol
+ {
+       int error;
+       char * to;
++      struct lookup_intent it = { .it_op = IT_LINK };
+       to = getname(newname);
+       error = PTR_ERR(to);
+@@ -1667,7 +1788,7 @@ asmlinkage long sys_link(const char * ol
+               struct dentry *new_dentry;
+               struct nameidata nd, old_nd;
+-              error = __user_walk(oldname, LOOKUP_POSITIVE, &old_nd);
++              error = __user_walk_it(oldname, LOOKUP_POSITIVE, &old_nd, &it);
+               if (error)
+                       goto exit;
+               error = path_lookup(to, LOOKUP_PARENT, &nd);
+@@ -1676,10 +1797,12 @@ asmlinkage long sys_link(const char * ol
+               error = -EXDEV;
+               if (old_nd.mnt != nd.mnt)
+                       goto out_release;
+-              new_dentry = lookup_create(&nd, 0);
++              it.it_op = IT_LINK2;
++              new_dentry = lookup_create(&nd, 0, &it);
+               error = PTR_ERR(new_dentry);
+               if (!IS_ERR(new_dentry)) {
+                       error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
++                      intent_release(new_dentry, &it);
+                       dput(new_dentry);
+               }
+               up(&nd.dentry->d_inode->i_sem);
+@@ -1720,7 +1843,8 @@ exit:
+  *       locking].
+  */
+ int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
+-             struct inode *new_dir, struct dentry *new_dentry)
++                 struct inode *new_dir, struct dentry *new_dentry,
++                 struct lookup_intent *it)
+ {
+       int error;
+       struct inode *target;
+@@ -1778,6 +1902,7 @@ int vfs_rename_dir(struct inode *old_dir
+               error = -EBUSY;
+       else 
+               error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry);
++      intent_release(new_dentry, it);
+       if (target) {
+               if (!error)
+                       target->i_flags |= S_DEAD;
+@@ -1799,7 +1924,8 @@ out_unlock:
+ }
+ int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
+-             struct inode *new_dir, struct dentry *new_dentry)
++                   struct inode *new_dir, struct dentry *new_dentry,
++                   struct lookup_intent *it)
+ {
+       int error;
+@@ -1830,6 +1956,7 @@ int vfs_rename_other(struct inode *old_d
+               error = -EBUSY;
+       else
+               error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry);
++      intent_release(new_dentry, it);
+       double_up(&old_dir->i_zombie, &new_dir->i_zombie);
+       if (error)
+               return error;
+@@ -1841,13 +1968,14 @@ int vfs_rename_other(struct inode *old_d
+ }
+ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
+-             struct inode *new_dir, struct dentry *new_dentry)
++             struct inode *new_dir, struct dentry *new_dentry,
++             struct lookup_intent *it)
+ {
+       int error;
+       if (S_ISDIR(old_dentry->d_inode->i_mode))
+-              error = vfs_rename_dir(old_dir,old_dentry,new_dir,new_dentry);
++              error = vfs_rename_dir(old_dir,old_dentry,new_dir,new_dentry,it);
+       else
+-              error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry);
++              error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry,it);
+       if (!error) {
+               if (old_dir == new_dir)
+                       inode_dir_notify(old_dir, DN_RENAME);
+@@ -1864,6 +1992,7 @@ static inline int do_rename(const char *
+       int error = 0;
+       struct dentry * old_dir, * new_dir;
+       struct dentry * old_dentry, *new_dentry;
++      struct lookup_intent it = { .it_op = IT_RENAME };
+       struct nameidata oldnd, newnd;
+       error = path_lookup(oldname, LOOKUP_PARENT, &oldnd);
+@@ -1889,7 +2018,7 @@ static inline int do_rename(const char *
+       double_lock(new_dir, old_dir);
+-      old_dentry = lookup_hash(&oldnd.last, old_dir);
++      old_dentry = lookup_hash_it(&oldnd.last, old_dir, &it);
+       error = PTR_ERR(old_dentry);
+       if (IS_ERR(old_dentry))
+               goto exit3;
+@@ -1905,18 +2034,21 @@ static inline int do_rename(const char *
+               if (newnd.last.name[newnd.last.len])
+                       goto exit4;
+       }
+-      new_dentry = lookup_hash(&newnd.last, new_dir);
++      it.it_op = IT_RENAME2;
++      new_dentry = lookup_hash_it(&newnd.last, new_dir, &it);
+       error = PTR_ERR(new_dentry);
+       if (IS_ERR(new_dentry))
+               goto exit4;
+       lock_kernel();
+       error = vfs_rename(old_dir->d_inode, old_dentry,
+-                                 new_dir->d_inode, new_dentry);
++                                 new_dir->d_inode, new_dentry, &it);
+       unlock_kernel();
++      intent_release(new_dentry, &it);
+       dput(new_dentry);
+ exit4:
++      intent_release(old_dentry, &it);
+       dput(old_dentry);
+ exit3:
+       double_up(&new_dir->d_inode->i_sem, &old_dir->d_inode->i_sem);
+@@ -1965,7 +2097,8 @@ out:
+ }
+ static inline int
+-__vfs_follow_link(struct nameidata *nd, const char *link)
++__vfs_follow_link(struct nameidata *nd, const char *link, 
++                     struct lookup_intent *it)
+ {
+       int res = 0;
+       char *name;
+@@ -1978,7 +2111,7 @@ __vfs_follow_link(struct nameidata *nd, 
+                       /* weird __emul_prefix() stuff did it */
+                       goto out;
+       }
+-      res = link_path_walk(link, nd);
++      res = link_path_walk_it(link, nd, it);
+ out:
+       if (current->link_count || res || nd->last_type!=LAST_NORM)
+               return res;
+@@ -2000,7 +2133,13 @@ fail:
+ int vfs_follow_link(struct nameidata *nd, const char *link)
+ {
+-      return __vfs_follow_link(nd, link);
++      return __vfs_follow_link(nd, link, NULL);
++}
++
++int vfs_follow_link_it(struct nameidata *nd, const char *link, 
++                       struct lookup_intent *it)
++{
++      return __vfs_follow_link(nd, link, it);
+ }
+ /* get the link contents into pagecache */
+@@ -2042,7 +2181,7 @@ int page_follow_link(struct dentry *dent
+ {
+       struct page *page = NULL;
+       char *s = page_getlink(dentry, &page);
+-      int res = __vfs_follow_link(nd, s);
++      int res = __vfs_follow_link(nd, s, NULL);
+       if (page) {
+               kunmap(page);
+               page_cache_release(page);
+--- linux-2.4.18-17.8.0/fs/nfsd/vfs.c~vfs_intent       2002-12-06 14:52:31.000000000 -0800
++++ linux-2.4.18-17.8.0-zab/fs/nfsd/vfs.c      2002-12-06 14:52:31.000000000 -0800
+@@ -1298,7 +1298,7 @@ nfsd_rename(struct svc_rqst *rqstp, stru
+                       err = nfserr_perm;
+       } else
+ #endif
+-      err = vfs_rename(fdir, odentry, tdir, ndentry);
++      err = vfs_rename(fdir, odentry, tdir, ndentry, NULL);
+       unlock_kernel();
+       if (!err && EX_ISSYNC(tfhp->fh_export)) {
+               nfsd_sync_dir(tdentry);
+--- linux-2.4.18-17.8.0/fs/open.c~vfs_intent   2002-12-06 14:52:31.000000000 -0800
++++ linux-2.4.18-17.8.0-zab/fs/open.c  2002-12-06 14:52:31.000000000 -0800
+@@ -19,6 +19,9 @@
+ #include <asm/uaccess.h>
+ #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
++extern int path_walk_it(const char *name, struct nameidata *nd,
++                      struct lookup_intent *it);
++extern void intent_release(struct dentry *de, struct lookup_intent *it);
+ int vfs_statfs(struct super_block *sb, struct statfs *buf)
+ {
+@@ -118,12 +121,13 @@ static inline long do_sys_truncate(const
+       struct nameidata nd;
+       struct inode * inode;
+       int error;
++      struct lookup_intent it = { .it_op = IT_SETATTR };
+       error = -EINVAL;
+       if (length < 0) /* sorry, but loff_t says... */
+               goto out;
+-      error = user_path_walk(path, &nd);
++      error = user_path_walk_it(path, &nd, &it);
+       if (error)
+               goto out;
+       inode = nd.dentry->d_inode;
+@@ -168,6 +172,7 @@ static inline long do_sys_truncate(const
+       put_write_access(inode);
+ dput_and_out:
++      intent_release(nd.dentry, &it);
+       path_release(&nd);
+ out:
+       return error;
+@@ -259,8 +264,9 @@ asmlinkage long sys_utime(char * filenam
+       struct nameidata nd;
+       struct inode * inode;
+       struct iattr newattrs;
++      struct lookup_intent it = { .it_op = IT_SETATTR };
+-      error = user_path_walk(filename, &nd);
++      error = user_path_walk_it(filename, &nd, &it);
+       if (error)
+               goto out;
+       inode = nd.dentry->d_inode;
+@@ -286,6 +292,7 @@ asmlinkage long sys_utime(char * filenam
+       }
+       error = notify_change(nd.dentry, &newattrs);
+ dput_and_out:
++      intent_release(nd.dentry, &it);
+       path_release(&nd);
+ out:
+       return error;
+@@ -303,8 +310,9 @@ asmlinkage long sys_utimes(char * filena
+       struct nameidata nd;
+       struct inode * inode;
+       struct iattr newattrs;
++      struct lookup_intent it = { .it_op = IT_SETATTR };
+-      error = user_path_walk(filename, &nd);
++      error = user_path_walk_it(filename, &nd, &it);
+       if (error)
+               goto out;
+@@ -331,6 +339,7 @@ asmlinkage long sys_utimes(char * filena
+       }
+       error = notify_change(nd.dentry, &newattrs);
+ dput_and_out:
++      intent_release(nd.dentry, &it);
+       path_release(&nd);
+ out:
+       return error;
+@@ -347,6 +356,7 @@ asmlinkage long sys_access(const char * 
+       int old_fsuid, old_fsgid;
+       kernel_cap_t old_cap;
+       int res;
++      struct lookup_intent it = { .it_op = IT_GETATTR };
+       if (mode & ~S_IRWXO)    /* where's F_OK, X_OK, W_OK, R_OK? */
+               return -EINVAL;
+@@ -364,13 +374,14 @@ asmlinkage long sys_access(const char * 
+       else
+               current->cap_effective = current->cap_permitted;
+-      res = user_path_walk(filename, &nd);
++      res = user_path_walk_it(filename, &nd, &it);
+       if (!res) {
+               res = permission(nd.dentry->d_inode, mode);
+               /* SuS v2 requires we report a read only fs too */
+               if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
+                  && !special_file(nd.dentry->d_inode->i_mode))
+                       res = -EROFS;
++              intent_release(nd.dentry, &it);
+               path_release(&nd);
+       }
+@@ -385,8 +396,11 @@ asmlinkage long sys_chdir(const char * f
+ {
+       int error;
+       struct nameidata nd;
++      struct lookup_intent it = { .it_op = IT_GETATTR };
+-      error = __user_walk(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd);
++      error = __user_walk_it(filename,
++                             LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,
++                             &nd, &it);
+       if (error)
+               goto out;
+@@ -397,6 +411,7 @@ asmlinkage long sys_chdir(const char * f
+       set_fs_pwd(current->fs, nd.mnt, nd.dentry);
+ dput_and_out:
++      intent_release(nd.dentry, &it);
+       path_release(&nd);
+ out:
+       return error;
+@@ -436,9 +451,10 @@ asmlinkage long sys_chroot(const char * 
+ {
+       int error;
+       struct nameidata nd;
++      struct lookup_intent it = { .it_op = IT_GETATTR };
+-      error = __user_walk(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
+-                    LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
++      error = __user_walk_it(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
++                             LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd, &it);
+       if (error)
+               goto out;
+@@ -454,6 +470,7 @@ asmlinkage long sys_chroot(const char * 
+       set_fs_altroot();
+       error = 0;
+ dput_and_out:
++      intent_release(nd.dentry, &it);
+       path_release(&nd);
+ out:
+       return error;
+@@ -498,8 +515,9 @@ asmlinkage long sys_chmod(const char * f
+       struct inode * inode;
+       int error;
+       struct iattr newattrs;
++      struct lookup_intent it = { .it_op = IT_SETATTR };
+-      error = user_path_walk(filename, &nd);
++      error = user_path_walk_it(filename, &nd, &it);
+       if (error)
+               goto out;
+       inode = nd.dentry->d_inode;
+@@ -519,6 +537,7 @@ asmlinkage long sys_chmod(const char * f
+       error = notify_change(nd.dentry, &newattrs);
+ dput_and_out:
++      intent_release(nd.dentry, &it);
+       path_release(&nd);
+ out:
+       return error;
+@@ -588,10 +607,12 @@ asmlinkage long sys_chown(const char * f
+ {
+       struct nameidata nd;
+       int error;
++      struct lookup_intent it = { .it_op = IT_SETATTR };
+-      error = user_path_walk(filename, &nd);
++      error = user_path_walk_it(filename, &nd, &it);
+       if (!error) {
+               error = chown_common(nd.dentry, user, group);
++              intent_release(nd.dentry, &it);
+               path_release(&nd);
+       }
+       return error;
+@@ -601,10 +622,12 @@ asmlinkage long sys_lchown(const char * 
+ {
+       struct nameidata nd;
+       int error;
++      struct lookup_intent it = { .it_op = IT_SETATTR };
+-      error = user_path_walk_link(filename, &nd);
++      error = user_path_walk_link_it(filename, &nd, &it);
+       if (!error) {
+               error = chown_common(nd.dentry, user, group);
++              intent_release(nd.dentry, &it);
+               path_release(&nd);
+       }
+       return error;
+@@ -638,10 +661,16 @@ asmlinkage long sys_fchown(unsigned int 
+  * for the internal routines (ie open_namei()/follow_link() etc). 00 is
+  * used by symlinks.
+  */
++extern int open_namei_it(const char *filename, int namei_flags, int mode,
++                       struct nameidata *nd, struct lookup_intent *it);
++struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
++                          int flags, struct lookup_intent *it);
++
+ struct file *filp_open(const char * filename, int flags, int mode)
+ {
+       int namei_flags, error;
+       struct nameidata nd;
++      struct lookup_intent it = { .it_op = IT_OPEN };
+       namei_flags = flags;
+       if ((namei_flags+1) & O_ACCMODE)
+@@ -649,18 +678,19 @@ struct file *filp_open(const char * file
+       if (namei_flags & O_TRUNC)
+               namei_flags |= 2;
+-      error = open_namei(filename, namei_flags, mode, &nd);
+-      if (!error)
+-              return dentry_open(nd.dentry, nd.mnt, flags);
++      error = open_namei_it(filename, namei_flags, mode, &nd, &it);
++      if (error)
++              return ERR_PTR(error);
+-      return ERR_PTR(error);
++      return dentry_open_it(nd.dentry, nd.mnt, flags, &it);
+ }
+ extern ssize_t do_readahead(struct file *file, unsigned long index, unsigned long nr);
+ /* for files over a certains size it doesn't pay to do readahead on open */
+ #define READAHEAD_CUTOFF 48000
+-struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
++struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
++                          int flags, struct lookup_intent *it)
+ {
+       struct file * f;
+       struct inode *inode;
+@@ -711,6 +741,7 @@ struct file *dentry_open(struct dentry *
+               do_readahead(f, 0, (48 * 1024) >> PAGE_SHIFT);
+       
++      intent_release(dentry, it);
+       return f;
+ cleanup_all:
+@@ -725,11 +756,17 @@ cleanup_all:
+ cleanup_file:
+       put_filp(f);
+ cleanup_dentry:
++      intent_release(dentry, it);
+       dput(dentry);
+       mntput(mnt);
+       return ERR_PTR(error);
+ }
++struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
++{
++      return dentry_open_it(dentry, mnt, flags, NULL);
++}
++
+ /*
+  * Find an empty file descriptor entry, and mark it busy.
+  */
+--- linux-2.4.18-17.8.0/fs/stat.c~vfs_intent   2002-12-06 14:52:31.000000000 -0800
++++ linux-2.4.18-17.8.0-zab/fs/stat.c  2002-12-06 14:52:31.000000000 -0800
+@@ -13,6 +13,7 @@
+ #include <asm/uaccess.h>
++extern void intent_release(struct dentry *de, struct lookup_intent *it);
+ /*
+  * Revalidate the inode. This is required for proper NFS attribute caching.
+  */
+@@ -104,10 +105,12 @@ int vfs_stat(char *name, struct kstat *s
+ {
+       struct nameidata nd;
+       int error;
++      struct lookup_intent it = { .it_op = IT_GETATTR };
+-      error = user_path_walk(name, &nd);
++      error = user_path_walk_it(name, &nd, &it);
+       if (!error) {
+               error = do_getattr(nd.mnt, nd.dentry, stat);
++              intent_release(nd.dentry, &it);
+               path_release(&nd);
+       }
+       return error;
+@@ -117,10 +120,12 @@ int vfs_lstat(char *name, struct kstat *
+ {
+       struct nameidata nd;
+       int error;
++      struct lookup_intent it = { .it_op = IT_GETATTR };
+-      error = user_path_walk_link(name, &nd);
++      error = user_path_walk_link_it(name, &nd, &it);
+       if (!error) {
+               error = do_getattr(nd.mnt, nd.dentry, stat);
++              intent_release(nd.dentry, &it);
+               path_release(&nd);
+       }
+       return error;
+--- linux-2.4.18-17.8.0/include/linux/dcache.h~vfs_intent      2002-12-06 14:52:31.000000000 -0800
++++ linux-2.4.18-17.8.0-zab/include/linux/dcache.h     2002-12-06 14:52:31.000000000 -0800
+@@ -6,6 +6,34 @@
+ #include <asm/atomic.h>
+ #include <linux/mount.h>
++#define IT_OPEN  (1)
++#define IT_CREAT  (1<<1)
++#define IT_MKDIR  (1<<2)
++#define IT_LINK  (1<<3)
++#define IT_LINK2  (1<<4)
++#define IT_SYMLINK  (1<<5)
++#define IT_UNLINK  (1<<6)
++#define IT_RMDIR  (1<<7)
++#define IT_RENAME  (1<<8)
++#define IT_RENAME2  (1<<9)
++#define IT_READDIR  (1<<10)
++#define IT_GETATTR  (1<<11)
++#define IT_SETATTR  (1<<12)
++#define IT_READLINK  (1<<13)
++#define IT_MKNOD  (1<<14)
++#define IT_LOOKUP  (1<<15)
++
++struct lookup_intent {
++      int it_op;
++      int it_mode;
++      int it_disposition;
++      int it_status;
++      struct iattr *it_iattr;
++      __u64 it_lock_handle[2];
++      int it_lock_mode;
++      void *it_data;
++};
++
+ /*
+  * linux/include/linux/dcache.h
+  *
+@@ -78,6 +106,7 @@ struct dentry {
+       unsigned long d_time;           /* used by d_revalidate */
+       struct dentry_operations  *d_op;
+       struct super_block * d_sb;      /* The root of the dentry tree */
++      struct lookup_intent *d_it;
+       unsigned long d_vfs_flags;
+       void * d_fsdata;                /* fs-specific data */
+       void * d_extra_attributes;      /* TUX-specific data */
+@@ -91,6 +120,8 @@ struct dentry_operations {
+       int (*d_delete)(struct dentry *);
+       void (*d_release)(struct dentry *);
+       void (*d_iput)(struct dentry *, struct inode *);
++      int (*d_revalidate2)(struct dentry *, int, struct lookup_intent *);
++      void (*d_intent_release)(struct dentry *, struct lookup_intent *);
+ };
+ /* the dentry parameter passed to d_hash and d_compare is the parent
+--- linux-2.4.18-17.8.0/include/linux/fs.h~vfs_intent  2002-12-06 14:52:31.000000000 -0800
++++ linux-2.4.18-17.8.0-zab/include/linux/fs.h 2002-12-06 14:52:31.000000000 -0800
+@@ -576,6 +576,7 @@ struct file {
+       /* needed for tty driver, and maybe others */
+       void                    *private_data;
++      struct lookup_intent    *f_intent;
+       /* preallocated helper kiobuf to speedup O_DIRECT */
+       struct kiobuf           *f_iobuf;
+@@ -836,7 +837,9 @@ extern int vfs_symlink(struct inode *, s
+ extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
+ extern int vfs_rmdir(struct inode *, struct dentry *);
+ extern int vfs_unlink(struct inode *, struct dentry *);
+-extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
++int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
++              struct inode *new_dir, struct dentry *new_dentry,
++              struct lookup_intent *it);
+ /*
+  * File types
+@@ -897,6 +900,7 @@ struct file_operations {
+ struct inode_operations {
+       int (*create) (struct inode *,struct dentry *,int);
+       struct dentry * (*lookup) (struct inode *,struct dentry *);
++      struct dentry * (*lookup2) (struct inode *,struct dentry *, struct lookup_intent *);
+       int (*link) (struct dentry *,struct inode *,struct dentry *);
+       int (*unlink) (struct inode *,struct dentry *);
+       int (*symlink) (struct inode *,struct dentry *,const char *);
+@@ -907,6 +911,8 @@ struct inode_operations {
+                       struct inode *, struct dentry *);
+       int (*readlink) (struct dentry *, char *,int);
+       int (*follow_link) (struct dentry *, struct nameidata *);
++      int (*follow_link2) (struct dentry *, struct nameidata *, 
++                            struct lookup_intent *it);
+       void (*truncate) (struct inode *);
+       int (*permission) (struct inode *, int);
+       int (*revalidate) (struct dentry *);
+@@ -1381,6 +1387,7 @@ typedef int (*read_actor_t)(read_descrip
+ extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
+ extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
++extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
+ extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
+ extern int FASTCALL(path_walk(const char *, struct nameidata *));
+ extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
+@@ -1392,6 +1399,8 @@ extern struct dentry * lookup_one_len(co
+ extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
+ #define user_path_walk(name,nd)        __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
+ #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
++#define user_path_walk_it(name,nd,it)  __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
++#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
+ extern void inode_init_once(struct inode *);
+ extern void iput(struct inode *);
+@@ -1492,6 +1501,8 @@ extern struct file_operations generic_ro
+ extern int vfs_readlink(struct dentry *, char *, int, const char *);
+ extern int vfs_follow_link(struct nameidata *, const char *);
++extern int vfs_follow_link_it(struct nameidata *, const char *, 
++                              struct lookup_intent *it);
+ extern int page_readlink(struct dentry *, char *, int);
+ extern int page_follow_link(struct dentry *, struct nameidata *);
+ extern struct inode_operations page_symlink_inode_operations;
+--- linux-2.4.18-17.8.0/kernel/ksyms.c~vfs_intent      2002-12-06 14:52:31.000000000 -0800
++++ linux-2.4.18-17.8.0-zab/kernel/ksyms.c     2002-12-06 14:52:31.000000000 -0800
+@@ -293,6 +293,7 @@ EXPORT_SYMBOL(read_cache_page);
+ EXPORT_SYMBOL(set_page_dirty);
+ EXPORT_SYMBOL(vfs_readlink);
+ EXPORT_SYMBOL(vfs_follow_link);
++EXPORT_SYMBOL(vfs_follow_link_it);
+ EXPORT_SYMBOL(page_readlink);
+ EXPORT_SYMBOL(page_follow_link);
+ EXPORT_SYMBOL(page_symlink_inode_operations);
+
+_
diff --git a/lustre/kernel_patches/pc/dev_read_only.pc b/lustre/kernel_patches/pc/dev_read_only.pc
new file mode 100644 (file)
index 0000000..4760ad1
--- /dev/null
@@ -0,0 +1,3 @@
+drivers/block/blkpg.c
+drivers/block/loop.c
+drivers/ide/ide-disk.c
diff --git a/lustre/kernel_patches/pc/exports.pc b/lustre/kernel_patches/pc/exports.pc
new file mode 100644 (file)
index 0000000..6472a11
--- /dev/null
@@ -0,0 +1,4 @@
+fs/ext3/Makefile
+fs/ext3/super.c
+include/linux/fs.h
+kernel/ksyms.c
diff --git a/lustre/kernel_patches/pc/kmem_cache_validate.pc b/lustre/kernel_patches/pc/kmem_cache_validate.pc
new file mode 100644 (file)
index 0000000..12f8816
--- /dev/null
@@ -0,0 +1,6 @@
+arch/i386/mm/init.c
+arch/ia64/mm/init.c
+include/linux/slab.h
+kernel/ksyms.c
+kernel/ksyms.c.validate
+mm/slab.c
diff --git a/lustre/kernel_patches/pc/lustre_version.pc b/lustre/kernel_patches/pc/lustre_version.pc
new file mode 100644 (file)
index 0000000..898bebd
--- /dev/null
@@ -0,0 +1 @@
+include/linux/lustre_version.h
diff --git a/lustre/kernel_patches/pc/uml_check_get_page.pc b/lustre/kernel_patches/pc/uml_check_get_page.pc
new file mode 100644 (file)
index 0000000..3dbf042
--- /dev/null
@@ -0,0 +1,2 @@
+arch/um/kernel/mem.c
+arch/um/kernel/mem.c.uml-fixes
diff --git a/lustre/kernel_patches/pc/uml_compile_fixes.pc b/lustre/kernel_patches/pc/uml_compile_fixes.pc
new file mode 100644 (file)
index 0000000..c1caa12
--- /dev/null
@@ -0,0 +1,2 @@
+include/asm-um/pgtable.h
+include/asm-um/pgtable.h.orig
diff --git a/lustre/kernel_patches/pc/uml_no_panic.pc b/lustre/kernel_patches/pc/uml_no_panic.pc
new file mode 100644 (file)
index 0000000..3dbf042
--- /dev/null
@@ -0,0 +1,2 @@
+arch/um/kernel/mem.c
+arch/um/kernel/mem.c.uml-fixes
diff --git a/lustre/kernel_patches/pc/vfs_intent.pc b/lustre/kernel_patches/pc/vfs_intent.pc
new file mode 100644 (file)
index 0000000..881576c
--- /dev/null
@@ -0,0 +1,8 @@
+fs/dcache.c
+fs/namei.c
+fs/nfsd/vfs.c
+fs/open.c
+fs/stat.c
+include/linux/dcache.h
+include/linux/fs.h
+kernel/ksyms.c
diff --git a/lustre/kernel_patches/prepare_tree.sh b/lustre/kernel_patches/prepare_tree.sh
new file mode 100755 (executable)
index 0000000..f512132
--- /dev/null
@@ -0,0 +1,88 @@
+#!/bin/bash
+
+die() {
+       echo -e $* >&2
+       echo aborting.. >&2
+       exit 1
+}
+
+canon() {
+       cd $1
+       CANON=$PWD
+       cd -
+}
+
+canon $(dirname $0)
+MYDIR=$CANON
+
+while [ ${#*} -gt 1 ]; do
+        case "$1" in
+                -t)
+                        shift;
+                        TREE=$1
+                        ;;
+                -s)
+                        shift;
+                        SERIES=$1
+                        ;;
+                *)
+                       die "unknown argument $1"
+                        break;
+                        ;;
+        esac
+        shift;
+done
+
+[ -z "$TREE" -o -z "$SERIES" ] && die "I need a tree and series:\n\t$0 -t kernel_dir -s series_name"
+[ ! -d $TREE ] && die "kernel tree '$TREE' isn't a directory"
+SERIES=$(basename $SERIES)
+[ ! -f $MYDIR/series/$SERIES ] && die "no series file '$SERIES'"
+
+canon $TREE
+TREE=$CANON
+
+# patch scripts wants a relative path from the linux tree to
+# its patch pile :(
+
+MY=$(echo $MYDIR | sed -e 's_^/__')
+TR=$(echo $TREE | sed -e 's_^/__')
+
+while true ; do
+       M=$(echo $MY | cut -d/ -f 1)
+       T=$(echo $TR | cut -d/ -f 1)
+
+       if [ $M != $T ]; then
+               break;
+       fi
+
+       MY=$(echo $MY | cut -d/ -f 2-)
+       TR=$(echo $TR | cut -d/ -f 2-)
+done
+
+[ $MY == $MYDIR ] && die "bad! $MY == $MYDIR" 
+
+REVERSE=$(revpath $TR)${MY}
+ABSINO=$(stat $MYDIR | awk '($3 == "Inode:") {print $4}')
+REVINO=`(cd $TREE ; stat $REVERSE | awk '($3 == "Inode:") {print $4}')`
+
+[ $ABSINO != $REVINO ] && die "inodes differ, my reverse path is bad?"
+
+echo export PATCHSCRIPTS=$REVERSE
+
+cd $TREE
+ln -sf $REVERSE/series/$SERIES series
+
+PATH_ELEMENTS=$(echo $PATH | sed -e 's/:/ /g')
+
+NEW_PATH=$MYDIR/scripts
+
+for p in $PATH_ELEMENTS; do
+       if echo $p | grep kernel_patches/scripts > /dev/null 2>&1 ; then
+               continue;
+       fi
+       NEW_PATH="$NEW_PATH:$p"
+done
+
+echo export PATH=$NEW_PATH
+
+echo "'$TREE' successfully setup" >&2
diff --git a/lustre/kernel_patches/scripts/added-by-patch b/lustre/kernel_patches/scripts/added-by-patch
new file mode 100755 (executable)
index 0000000..e9ccef6
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh
+# Extract names of new files from a patch, print them out
+
+PATCHFILE=$1
+case "$PATCHFILE" in
+*.gz) CMD="gzip -d < $PATCHFILE";;
+*)    CMD="cat $PATCHFILE";;
+esac
+
+TMP=$(mktemp /tmp/abp.XXXXXX)
+
+eval $CMD | egrep '^--- .*1969|^--- .*1970' > $TMP
+sed -e 's@[^/]*/\([^   ]*\).*@\1@' < $TMP | sed -e 's@^linux/@@' | sort
+rm -f $TMP
diff --git a/lustre/kernel_patches/scripts/apatch b/lustre/kernel_patches/scripts/apatch
new file mode 100755 (executable)
index 0000000..4b63598
--- /dev/null
@@ -0,0 +1,98 @@
+#!/bin/sh
+
+. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
+       echo "Impossible to find my library 'patchfns'."
+       echo "Check your install, or go to the right directory"
+       exit 1
+}
+
+
+do_apply()
+{
+       FILES=$(cat $P/pc/$PATCH_NAME.pc)
+       for file in $FILES
+       do
+               copy_file_to_bup $file $PATCH_NAME
+       done
+
+       silent=-s
+       if [ $opt_force != 0 ]
+       then
+               silent=
+       fi
+
+       if patch -p1 $silent -i "$1" || [ $opt_force != 0 ]
+       then
+               true
+       else
+               echo SOMETHING WENT WRONG
+               exit 1
+       fi
+}
+
+add_to_db()
+{
+       basename "$1" >> "$DB"
+}
+
+usage()
+{
+       echo "Usage: apatch patchname"
+       exit 1
+}
+
+opt_force=0
+PATCH_NAMES=""
+
+for i in $*
+do
+       case "$i" in
+       -f)
+               opt_force=1;;
+       *)
+               PATCH_NAMES="$PATCH_NAMES $i"
+       esac
+done
+
+if [ x"$PATCH_NAMES" == x ]
+then
+       usage
+fi
+
+apatch()
+{
+       PATCH_NAME=$(stripit $1)
+
+       need_file_there $P/pc/$PATCH_NAME.pc
+
+       if is_applied "$PATCH_NAME"
+       then
+               echo "$PATCH_NAME" is already applied
+               exit 1
+       fi
+
+       if [ $opt_force != 0 ]
+       then
+               echo FORCING PATCH
+       fi
+
+       if [ $opt_force != 0 ] || can_apply $P/patches/"$PATCH_NAME".patch
+       then
+               do_apply $P/patches/"$PATCH_NAME".patch
+               add_to_db "$PATCH_NAME"
+               echo applied $PATCH_NAME
+               echo
+       else
+               echo "$PATCH_NAME" does not apply
+               exit 1
+       fi
+}
+
+for i in $PATCH_NAMES
+do
+       if ! apatch $i
+       then
+               exit 1
+       fi
+done
+
diff --git a/lustre/kernel_patches/scripts/combine-applied b/lustre/kernel_patches/scripts/combine-applied
new file mode 100755 (executable)
index 0000000..8768b29
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+#
+# Make superpatch from currently applied patches using combinediff.
+#
+
+. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
+       echo "Impossible to find my library 'patchfns'."
+       echo "Check your install, or go to the right directory"
+       exit 1
+}
+
+usage()
+{
+       echo "Usage: combine-applied output-file"
+       exit 1
+}
+
+if [ $# -ne 1 ] 
+then
+       usage
+fi
+
+need_file_there applied-patches
+CURRENT=$(mktemp /tmp/cmbd-XXXXXXXX)
+for FILE in `cat applied-patches`
+do
+       NEXT=$(mktemp /tmp/cmbd-XXXXXXXX)
+       if [ -f $P/patches/$FILE ] 
+       then
+               combinediff $CURRENT $P/patches/$FILE > $NEXT
+       elif [ -f $P/patches/$FILE.patch ]
+       then
+               combinediff $CURRENT $P/patches/$FILE.patch > $NEXT
+       elif [ -f $FILE ]
+       then
+               combinediff $CURRENT $FILE > $NEXT
+       fi
+       rm $CURRENT
+       CURRENT=$NEXT
+done
+
+mv $NEXT "$1"
diff --git a/lustre/kernel_patches/scripts/combine-series b/lustre/kernel_patches/scripts/combine-series
new file mode 100755 (executable)
index 0000000..d00ba36
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+#
+# Make superpatch from current series using combinediff.
+#
+
+. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
+       echo "Impossible to find my library 'patchfns'."
+       echo "Check your install, or go to the right directory"
+       exit 1
+}
+
+usage()
+{
+       echo "Usage: combine-series output-file"
+       exit 1
+}
+
+if [ $# -ne 1 ] 
+then
+       usage
+fi
+
+need_file_there series
+CURRENT=$(mktemp /tmp/cmbd-XXXXXXXX)
+for FILE in $(cat series)
+do
+       NEXT=$(mktemp /tmp/cmbd-XXXXXXXX)
+       if [ -f $P/patches/$FILE ] 
+       then
+               combinediff $CURRENT $P/patches/$FILE > $NEXT
+       elif [ -f $P/patches/$FILE.patch ]
+       then
+               combinediff $CURRENT $P/patches/$FILE.patch > $NEXT
+       elif [ -f $FILE ]
+       then
+               combinediff $CURRENT $FILE > $NEXT
+       fi
+       rm $CURRENT
+       CURRENT=$NEXT
+done
+
+mv $NEXT "$1"
diff --git a/lustre/kernel_patches/scripts/cvs-take-patch b/lustre/kernel_patches/scripts/cvs-take-patch
new file mode 100755 (executable)
index 0000000..c6a6a2a
--- /dev/null
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+doit()
+{
+       echo $*
+       $*
+}
+
+usage()
+{
+       echo "Usage: cvs-take-patch patch_file_name"
+       exit 1
+}
+
+#
+# Find the highest level directory in $1 which does not
+# contain the directory $2.  Return it in $MISSING
+#
+highest_missing()
+{
+       START_DIR="$1"
+       NAME="$2"
+       MISSING=""
+       WHERE=$(dirname "$START_DIR")
+       PREV_WHERE=$START_DIR
+       while [ x"$WHERE" != x"$PREV_WHERE" ]
+       do
+               WHERE="$PREV_WHERE"
+               if [ ! -d "$WHERE"/"$NAME" ]
+               then
+                       MISSING="$WHERE"
+               fi
+               PREV_WHERE=$(dirname "$WHERE")
+       done
+       echo highest_missing returns $MISSING
+}
+
+#
+# Add all new directries to CVS, top-down
+# $1: name of a directory
+# $2: name of the CVS directory
+#
+add_cvs_dirs()
+{
+       MISSING=foo
+       while [ "$MISSING" != "" ]
+       do
+               highest_missing $1 $2
+               if [ x"$MISSING" != "x" ]
+               then
+                       if [ ! -d "$MISSING"/"$2" ]
+                       then
+                               doit cvs add $MISSING
+                       fi
+               fi
+       done
+}
+
+PATCHFILE=$1
+
+REMOVEDFILES=$(removed-by-patch $PATCHFILE)
+if [ "$REMOVEDFILES" != "" ]
+then
+       doit cvs remove $REMOVEDFILES
+fi
+
+NEWFILES=$(added-by-patch $PATCHFILE)
+for i in $NEWFILES
+do
+       DIRNAME=$(dirname $i)
+       echo "Looking at $DIRNAME"
+       add_cvs_dirs $DIRNAME CVS
+done
+
+if [ "$NEWFILES" != "" ]
+then
+       doit cvs add $NEWFILES
+fi
diff --git a/lustre/kernel_patches/scripts/docco.txt b/lustre/kernel_patches/scripts/docco.txt
new file mode 100644 (file)
index 0000000..7d4c4b6
--- /dev/null
@@ -0,0 +1,708 @@
+Patch management scripts
+Andrew Morton <akpm@digeo.com>
+18 October 2002
+
+This is a description of a bunch of shell scripts which I use for
+managing kernel patches.  They are quite powerful.  They can be used on
+projects other than the linux kernel.  They are easy to use, and fast.
+
+You end up doing a ton of recompiling with these scripts, because
+you're pushing and popping all the time.  ccache takes away the pain of
+all that.  http://ccache.samba.org/ - be sure to put the cache
+directory on the same fs as where you're working so that ccache can use
+hardlinks.
+
+The key philosophical concept is that your primary output is patches. 
+Not ".c" files, not ".h" files.  But patches.  So patches are the
+first-class object here.
+
+Installation
+============
+
+You place all the scripts somewhere in your path, or in
+/usr/lib/patch-scripts.
+
+Terminology
+===========
+
+The patch scripts require three special directories called "pc",
+"patches" and "txt".
+
+If the environment variable PATCHSCRIPTS is set, it is taken to to be
+the directory in which those three directories reside.  Typically, it
+would be a relative pathname.  So
+
+       setenv PATCHSCRIPTS ./i-put-them-here
+
+would tell the patch scripts to look in ./i-put-them-here/pc, etc.
+
+If PATCHSCRIPTS is not set, and the directory ./patch-scripts is
+present then the patch scripts will us ./patch-scripts/pc/,
+./patch-scripts/patches/ and ./patch-scripts/txt/.
+
+Otherwise, the patch scripts use ./pc, ./patches and ./txt.
+
+In this document, the symbol $P is used to describe the directory which
+holds the pc/, patches/ and txt/ directories, as determined by the
+above search.
+
+It is expected that $P will always expand to a relative path.
+
+Concepts
+========
+
+All work occurs with a single directory tree.  All commands are invoked
+within the root of that tree.  The scripts manage a "stack" of patches.
+
+Each patch is a changeset against the base tree plus the preceding patches.
+
+All patches are listed, in order, in the file ./series.  You manage the
+series file.
+
+Any currently-applied patches are described in the file
+./applied-patches.  The patch scripts manage this file.
+
+Each patch affects a number of files in the tree.  These files are
+listed in a "patch control" file.  These .pc files live in the
+directory $P/pc/
+
+Patches are placed in the directory $P/patches/
+
+Documentation for the patches is placed in $P/txt/
+
+So for a particular patch "my-first-patch" the following will exist:
+
+- An entry "my-first-patch.patch" in ./series
+
+- An entry "my-first-patch" in ./applied-patches (if it's currently applied)
+
+- A file $P/pc/my-first-patch.pc which contains the names of the
+  files which my-first-patch modifies, adds or removes
+
+- A file $P/txt/my-first-patch.txt which contains the patch's
+  changelog.
+
+- A file $P/patches/my-first-patch.patch, which is the output of the
+  patch scripts.
+
+Operation
+=========
+
+When a patch "my-patch" is applied with apatch, or with pushpatch
+(which calls apatch), all the affected files (from $P/pc/my-patch.pc)
+are copied to files with ~my-patch appended.  So if $P/pc/my-patch.pc
+contained
+
+       kernel/sched.c
+       fs/inode.c
+
+then apatch will copy those files into kernel/sched.c~my-patch and
+fs/inode.c~my-patch.  It will then apply the patch to kernel/sched.c
+and fs/inode.c
+
+When a diff is regenerated by refpatch (which calls mpatch), the diff
+is made between kernel/sched.c and kernel/sched.c~my-patch.  How do the
+scripts know to use "~my-patch"?  Because my-patch is the current
+topmost patch.  It's the last line in ./applied-patches.
+
+In this way, the whole thing is stackable.  If you have four patches
+applied, say "patch-1", "patch-2", "patch-3" and "patch-4", and if
+patch-2 and patch-4 both touch kernel/sched.c then you will have:
+
+       kernel/sched.c~patch-2          Original copy, before patch-2
+       kernel/sched.c~patch-4          Copy before patch-4.  Contains changes
+                                       from patch-2
+       kernel/sched.c                  Current working copy.  Contains changes
+                                       from patch-4.
+
+This means that your diff headers contain "~patch-name" in them, which
+is convenient documentation.
+
+Walkthrough
+===========
+
+Let's start.
+
+Go into /usr/src/linux (or wherever)
+
+       mkdir pc patches txt
+
+Now let's generate a patch
+
+       fpatch my-patch kernel/sched.c
+
+OK, we've copied kernel/sched.c to kernel/sched.c~my-patch.  We've
+appended "my-patch" to ./applied-patches and we've put "kernel/sched.c"
+into the patch control file, pc/my-patch.pc.
+
+       Now edit kernel/sched.c a bit.
+
+Now we're ready to document the patch
+
+       Now write txt/my-patch.txt
+
+Now generate the patch
+
+       refpatch
+
+This will generate patches/my-patch.patch.  Take a look.
+
+Now remove the patch
+
+       poppatch
+
+applied-patches is now empty, and the patch is removed.
+
+Now let's add a file to my-patch and then generate my-second-patch:
+
+       Add "my-patch.patch" to ./series (no blank lines in that file please)
+
+       pushpatch
+
+OK, the patch is applied again.  Let's add another file
+
+       fpatch kernel/printk.c
+
+Note that here we gave fpatch a single argument.  So rather than
+opening a new patch, it adds kernel/printk.c to the existing topmost
+patch.  That's my-patch.
+
+       Edit kernel/printk.c
+
+Refresh my-patch (you end up running refpatch a lot)
+
+       refpatch
+
+Now start a second patch:
+
+       fpatch my-second-patch kernel/sched.c
+
+Now take a look at applied-patches.  Also do an `ls kernel/sched*'.
+
+       Edit kernel/sched.c, to make some changes for my-second-patch
+
+Generate my-second-patch:
+
+       refpatch
+
+Take a look in patches/my-second-patch.patch
+
+Don't forget to add "my-second-patch.patch" to the series file.
+
+And remove both patches:
+
+       poppatch
+       poppatch
+
+
+That's pretty much it, really.
+
+
+Command reference
+=================
+
+Generally, where any of these commands take a "patch-name", that can be
+of the form txt/patch-name.txt, patch-name.pc, just patch-name or
+whatever.  The scripts will strip off a leading "txt/", "patches/" or
+"pc/" and any trailing extension.  This is so you can do
+
+       apatch patches/a<tab>
+
+to conveniently use shell tabbing to select patch names.
+
+
+
+added-by-patch
+
+  Some internal thing.
+
+apatch [-f] patch-name
+
+  This is the low-level function which adds patches.  It does the
+  copying into ~-files and updates the applied-patches file.  It
+  applies the actual patch.
+
+  apatch will do a patch --dry-run first and will refuse to apply the
+  patch if the dryrun fails.
+
+  So when you are getting rejects you do this:
+
+       pushpatch               # This fails, due to rejects.  Drat.
+       apatch -f patch-name    # Force the patch
+  (or)  pushpatch -f           # Force the patch
+
+  OK, you've now applied patch-name, but you have rejects.  Go fix
+  those up and do
+
+       refpatch
+
+  And you're ready to move on.
+
+combine-series output-file
+
+  It incrementally combinediffs all the patches in series to make a
+  complete patch for the series.  Requires combinediff frmo patchutils.
+
+  See http://cyberelk.net/tim/patchutils/ (Don't download the
+  "experimental" patchutils - it seems to only have half of the
+  commands in it.  Go for "stable")
+
+cvs-take-patch
+
+  I forget.
+
+export_patch
+
+  export the patches listed in ./series to a set of files which
+  are named in such a way that the sort order is the same as the
+  order of the series file. 
+
+  Usage:  export_patch directory [prefix]
+
+  Example:
+       
+       Suppose ./series contains
+       
+       mango.patch
+       orange.patch
+       banana.patch
+       apple.patch
+       pear.patch
+
+       export_patch ../mypatches fruit 
+       
+       The patches would be copied to
+
+       ../mypatches/p00001_fruit_mango.patch
+       ../mypatches/p00002_fruit_orange.patch
+       ../mypatches/p00003_fruit_banana.patch
+       ../mypatches/p00003_fruit_banana.patch
+       ../mypatches/p00003_fruit_banana.patch
+
+       Named in this way, someone may easily apply them:
+
+       cat mypatches/p*fruit* | patch -p1
+
+       If prefix is omitted, the patchnames will be transformed
+       such that "original.patch" becomes "pXXXXX_original.patch".
+
+fpatch [patch-name] foo.c
+
+  If patch-name is given, fpatch will start a new patch which
+  modifies (or adds, or removes) the single file foo.c.  It updates
+  ./applied-patches and creates pc/patch-name.pc.  fpatch will copy
+  foo.c to foo.c~patch-name in preparation for edits of foo.c.
+
+  If patch-name is not given then fpatch will add foo.c to the
+  current topmost patch.  It will add "foo.c" to $P/pc/$(toppatch).pc. 
+  It will copy foo.c to foo.c~$(toppatch).
+
+import_patch
+
+  Imports a set of patch files, creating $P/pc, $P/txt, $P/patches and
+  ./series as necessary.  It also creates $P/txt/*.txt by stripping 
+  off the top of the patches (and removes any diffstat output it finds, 
+  so that it can eat refpatch output and export_patch output.)  The 
+  imported patch names are appended to the series file.
+
+  In creating the $P/txt/*.txt files, mail headers are stripped with 
+  formail, preserving the "From:" and "Subject:" lines.  "DESC" and
+  "EDESC" markers are added if they are not already present, using the
+  "From:" and "Subject:" lines for the DESC portion, if they are present.
+  (See "patchdesc" command, below, for more on these markers.)
+
+  Also, it can rename the patch file as it is imported by stripping out
+  a pattern.  This is useful if, as often is the case, you have patch 
+  sets with filenames designed to help sort the patches into the correct 
+  order, such as "p001_xxx_funky_stuff.patch" you can have it automatically
+  renamed to funky_stuff.patch on import, and let the series file manage
+  the ordering.
+
+  Import_patch will uncompress patches (*.Z, *.bz2, *.gz) as necessary.
+
+  Usage:
+
+  import_patch [-p pattern] patchfile ...
+
+  Example:
+
+       % ls ../fruit/p*patch
+       ../fruit/p00001_northern_apple.patch
+       ../fruit/p00001_tropical_mango.patch
+       ../fruit/p00002_northern_pear.patch
+       ../fruit/p00002_tropical_orange.patch
+       ../fruit/p00003_tropical_banana.patch
+       % import_patch -p 'p[0-9]*_tropical_' ../fruit/p*tropical*
+       Recreated pc/mango.pc
+       Recreated pc/orange.pc
+       Recreated pc/banana.pc
+       % import_patch -p 'p[0-9]*_northern_' ../fruit/p*northern*
+       Recreated pc/apple.pc
+       Recreated pc/pear.pc
+
+  Then you can "pushpatch; refpatch" 5 times.
+
+inpatch
+
+  List the names of ths files which are affected by the current
+  topmost patch.
+
+  This is basically
+
+       cat pc/$(toppatch).pc
+
+mpatch
+
+  A low-level thing to generate patches
+
+new-kernel
+
+  Some thing I use for importing a new kernel from kernel.org
+
+p0-2-p1
+
+  Internal thing to convert patch -p0 form into patch -p1
+
+patchdesc
+
+  Generates a single-line description of a patch.
+
+  The txt/my-patch.txt files have the following format:
+
+  <start of file>
+  DESC
+  some short description
+  EDESC
+
+  The long description
+  <end of file>
+
+  I use
+
+       patchdesc $(cat series)
+
+  to generate short-form summaries of the patch series.
+
+patchfns
+
+  Internal utilities
+
+pcpatch
+
+  Standalone tool to generate a .pc file from a patch.
+
+  Say someone sends you "his-patch.diff".  What you do is:
+
+       cp ~/his-patch.diff patches/his-patch.patch
+       pcpatch his-patch
+
+  This generates $P/pc/his-patch.pc and you're all set.  Add
+  "his-patch.patch" to ./series in the right place and start pushing.
+
+p_diff
+
+  I forget
+
+poppatch
+
+  Remove one or more patches from the current stack.  This command
+  does *not* use the series file.  It works purely against
+  applied-patches.
+
+  Usage:
+
+       poppatch
+               Remove the topmost patch
+       poppatch 10
+               Remove ten patches
+       poppatch some-patch-name[.patch]
+               Remove patches until "some-patch-name" is top patch
+
+pstatus
+
+       Shows status of patches
+
+  Usage:
+       pstatus [patchfile ...]
+       
+       One line per patch is output showing:
+       1: Patch number in the series file
+       2: Whether the patch is currently applied
+       3: Name of patch
+       4: Status of the patch (needs pcpatch, changelog, refpatch)
+
+       If no patchfiles are specified, $P/patches/*.patch
+       are assumed.
+
+  Caveats:
+       A patch set which contains separate patches to add a file
+       and modify that same file may give spurious "Needs refpatch"
+       status for the patch which adds the file or the topmost patch.
+
+ptkdiff
+
+  Two modes:
+
+       ptkdiff -
+
+               Run tkdiff against all the file affected
+               by $(toppatch).  The diff is only for the changes made
+               by the top patch! ie: it's between "filename" and
+               "filename~toppatch-name".
+
+       ptkdiff filename
+
+               Just run tkdiff against that file,
+               showing the changes which are due to toppatch.
+
+pushpatch [-f]
+
+  Apply the next patch, from the series file.
+
+  This consults ./applied-patches to find out the top patch, then
+  consults ./series to find the next patch.  And pushes it.
+
+    pushpatch
+
+      Apply the next patch
+
+    pushpatch 10
+      Apply the next ten patches
+
+    pushpatch some-patch-name
+
+      Keep pushing patches until "some-patch-name" is toppatch
+
+    pushpatch -f
+
+      Push the next patch, ignoring rejects.
+
+refpatch
+
+    regnerates the topmost patch.  Reads all the affected files
+    from pc/$(toppatch).pc and diffs them against their tilde-files.
+
+    Also pastes into the patch your patch documentation and
+    generates a diffstat summary.
+
+removed-by-patch
+
+  Some thing.
+
+rename-patch
+
+  CVS rename for patches.
+
+rolled-up-patch
+
+  Bit of a hack.  Is designed to generate a rolled-up diff of all
+  currently-applied patches.  But it requires a ../linux-2.x.y tree to
+  diff against.  Needs to be redone.
+
+rpatch
+
+  Internal command
+
+split-patch
+
+  Some thing someone write to split patches up.  I don't use it.
+
+tag-series
+
+  Assuming you keep pc/*, patches/* and txt/* under CVS revision
+  control, tag-series allows you to tag a patchset's individual
+  components.  I use
+
+       tag-series s2_5_44-mm3 pc/2.5.44-mm3-series
+
+  which will attach the cvs tag "s2_5_44-mm3" to every .pc, .patch
+  and .txt file which is mentioned in the series file
+  "pc/2.5.44-mm3-series".
+
+  It will also tag pc/2.5.44-mm3-series, which is a bit redundant
+  given that I use a different series file for each patchset release..
+
+
+toppatch
+
+  Print the name of the topmost patch.  From ./applied-patches
+
+touched-by-patch patch-filename
+
+  List the names of files which are affected by a diff.
+
+unitdiff.py
+
+  Rasmus Andersen's script to convert a diff into minimum-context
+  form.  This form has a better chance of applying if you're getting
+  nasty rejects.  But patch can and will make mistakes when fed
+  small-context input.
+
+
+Work Practices
+==============
+
+I keep the kernel tree, the $P/pc/, $P/patches/ and $P/txt/ contents under
+CVS control.  This is important...
+
+I have several "series" files.  I keep these in $P/pc/foo-series and use
+
+       ln -s pc/foo-series series
+
+when I'm working on foo.
+
+If someone sends me a patch I'll do:
+
+       cp ~/whatever patches/his-patch.patch
+       pcpatch his-patch
+       apatch his-patch
+
+  If apatch fails then run `apatch -f his-patch' and fix the rejects.
+
+       refpatch
+
+  to clean up any fuzz.
+
+       poppatch
+       cvs add pc/his-patch.pc patches/his-patch.patch
+       cvs commit pc patches
+
+  Now edit ./series and place "his-patch.patch" in the appropriate place.
+
+
+If you're working on a particular patch (say, "dud-patch") and you
+balls something up, just run:
+
+       refpatch        # Generate the crap patch
+       poppatch        # Remove it all
+       rm patches/dud-patch.patch
+       cvs up patches/dud-patch.patch
+
+and all is well.
+
+
+Getting updates from Linus
+==========================
+
+What I do is to grab the latest -bk diff from
+http://www.kernel.org/pub/linux/kernel/people/dwmw2/bk-2.5/
+and do:
+
+       gzip -d < cs<tab> > patches/linus.patch
+       pcpatch linus
+       apatch linus | grep diff
+
+               Now fix up all the files which got deleted,
+               because there's something wrong with bitkeeper diffs:
+
+       cvs up -ko <missing files from the above diff>
+
+       apatch linus
+       $EDITOR linus/linus.txt
+       
+               Add the changeset number to txt/linus.txt
+
+       refpatch
+       poppatch
+
+  Now add "linus.patch" as the first entry in your ./series file and
+  start pushing your other patches on top of that.
+
+BUGS
+====
+
+Tons and tons.  The scripts are fragile, the error handling is ungraceful and
+if you do something silly you can end up in a pickle.
+
+Generally the scripts are very careful to not wreck your files or your
+patches.  But they can get the ./applied-patches and ~-files into an
+awkward state.
+
+Usually you can sort it out by copying the ~-files back onto the originals
+and removing the last line from ./applied-patches.  Or do a "refpatch ;
+poppatch ; rm patches/troublesome-patch.patch ; cvs up patches".
+
+If it's really bad, just blow away the entire tree and do a new CVS checkout.
+
+
+Working on non-kernel projects
+==============================
+
+Well it's the same thing.  Say you've downloaded a copy of util-linux
+and you want to make a change:
+
+       cd /usr/src
+       tar xvfz ~/util-linux.tar.gz
+       cd util-linux
+       mkdir pc patches txt
+       fpatch my-patch sys-utils/rdev.c
+       fpatch sys-utils/ipcs.8
+       <edit, edit>
+       refpatch
+       <ship patches/my-patch.patch>
+
+How to balls things up
+======================
+
+Well here's one way.  Suppose you have 20 patches applied, and three of
+them (say, "p1", "p6" and "p11") all modify "foo.c".
+
+Now you go and change foo.c.
+
+Well, to which patch does that change belong?  You need to decide. 
+Let's say you decide "p6".
+
+If you run `refpatch' when "p11" is toppatch then you lose.  The diff
+went into p11.
+
+What you can do is:
+
+1:
+       poppatch p6
+       <edit>
+       refpatch
+       pushpatch p11
+       <test>
+
+  (See why ccache is looking good?)
+
+or
+
+2:
+       <edit>
+       <test>
+       poppatch p6     <hope like hell that the other patches remove cleanly>
+       refpatch
+
+
+Another good way of ballsing up is to cheat.  Say "oh I just want to make
+this one-line change".  And "oh, and this one".
+
+Now you're getting in a mess.  It's much, much better to just use the system:
+
+       fpatch junk file1
+       fpatch file2
+       <edit>
+       <play>
+       refpatch
+       poppatch
+       rm pc/junk.pc patches/junk.patch
+
+Merging with -mm kernels
+========================
+
+Haven't tried this, but it should work:
+
+- Grab all the patches from broken-out/, place them in your $P/patches/
+
+- Copy my series file into ./series (or $P/pc/akpm-series and symlink it)
+
+- pushpatch 99
+
+And you're off and running.  The nice thing about this is that you can
+send me incremental diffs to diffs which I already have.
+
+Or whatever.  I'm fairly handy with diffs nowadays.  Rejects are
+expected.  I just prefer to have "one concept per diff".
+
diff --git a/lustre/kernel_patches/scripts/export_patch b/lustre/kernel_patches/scripts/export_patch
new file mode 100755 (executable)
index 0000000..d378417
--- /dev/null
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
+       echo "Impossible to find my library 'patchfns'."
+       echo "Check your install, or go to the right directory"
+       exit 1
+}
+
+usage()
+{
+       echo "export_patch: export the patches listed in ./series" 1>&2
+       echo "usage: export_patch destination-directory [prefix] " 1>&2
+       exit 1
+}
+
+DIR="$1"
+PREFIX="$2""_"
+
+if [ "$DIR" = "" ]
+then
+       usage
+fi
+
+if [ -e "$DIR" -a ! -d "$DIR" ]
+then
+       echo "$DIR exists already, but is not a directory." 1>&2
+       exit 1
+fi
+
+if [ ! -r ./series ]
+then
+       echo "./series is not readable." 1>&2
+       exit 1
+fi
+
+mkdir -p "$DIR" || exit 1
+
+count=1
+for x in `cat ./series`
+do
+       fname=`echo "$count" "$PREFIX" "$x" |\
+                awk '{ if ( $2 != "_" )
+                               printf("p%05d_%s%s\n", $1, $2, $3); 
+                       else
+                               printf("p%05d_%s\n", $1, $3); 
+               }'`
+       if [ ! -r $P/patches/"$x" ]
+       then
+               echo "$P/patches/"$x" is not readable. skipping." 1>&2
+               continue;
+       fi
+       cp -f $P/patches/"$x" "$DIR"/"$fname" || continue; 
+       count=`expr $count + 1`
+done
+
diff --git a/lustre/kernel_patches/scripts/extract_description b/lustre/kernel_patches/scripts/extract_description
new file mode 100755 (executable)
index 0000000..6fa0e68
--- /dev/null
@@ -0,0 +1,87 @@
+#!/bin/sh
+
+insert_line()
+{
+       PATTERN="$1"
+       LINE="$2"
+       FILE="$3"
+       awk ' BEGIN { found=0; }
+               /'"$PATTERN"'/ { 
+                       print; 
+                       if (!found)
+                               printf("%s\n", "'$LINE'"); 
+                       found=1; 
+                       next;
+               }
+               { print; }
+       ' < "$FILE"
+}
+
+# extract the description from the top of a patch
+# filter stdin
+# collapse adjacent blank lines to a single blank line
+# remove any lines that look like diffstat output
+# stop output on encountering a line beginning with '---' (beginning of patch)
+
+       TMPFILE=`mktemp /tmp/xdtmp.XXXXXX` || exit 1
+       formail -kfcb -X 'From:' -X 'Subject:' |\
+       awk '
+               BEGIN { found_end=0; lastone="x"; }
+               /^ .* [|] +[0-9]+ [+-]+$/ { 
+                       #/* we found something like diffstat output... */
+                       if (found_end == 1) {
+                               /* we are past end of diffstat, let it pass */
+                               print;
+                       }
+                       next;
+               }
+               /^ [1-9][0-9]* files changed/ {
+                       #/* end of diffstat output, stop filtering diffstat */
+                       found_end=1;
+                       next;
+               }
+               /^--- / { exit; }
+               {
+                       #/* collapse adjacent blank lines to 1 blank line */ 
+                       if ( $0 == "" && lastone == "" )
+                               next;
+                       else 
+                               print; 
+                       lastone=$0;
+               }
+       ' | awk '{ if ($0 == "" && FNR == 1)  next; print; }' > "$TMPFILE"
+
+       descs=`head -10 $TMPFILE | grep -c '^[  ]*DESC[         ]*$'`
+       if [ "$descs" = "0" ]
+       then
+               # DESC is not 1st non blank line in the file
+               echo "DESC"
+               descs=0
+       fi
+       edescs=`grep -c '^EDESC$' "$TMPFILE"`
+       subjects=`grep -c '^[   ]*Subject[:]' "$TMPFILE"`
+       froms=`grep -c '^[      ]*From[:]' "$TMPFILE"`
+       if [ "$edescs" = "0" ]
+       then
+               if [ "$subjects" != "0" ]
+               then
+                       insert_line '^Subject[:]' 'EDESC' "$TMPFILE"
+               else
+                       if [ "$froms" != "0" ]
+                       then
+                               insert_line '^From[:]' 'EDESC' "$TMPFILE"
+                       else
+                               if [ "$descs" = "0" ]
+                               then
+                                       # blank DESC line...
+                                       echo '(undescribed patch)'
+                                       echo EDESC
+                                       cat "$TMPFILE"
+                               else
+                                       insert_line '^DESC$' "EDESC" "$TMPFILE"
+                               fi
+                       fi
+               fi
+       else
+               cat $TMPFILE
+       fi
diff --git a/lustre/kernel_patches/scripts/fpatch b/lustre/kernel_patches/scripts/fpatch
new file mode 100755 (executable)
index 0000000..0cafa65
--- /dev/null
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+#
+# Add a file to a patch.
+#
+
+. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
+       echo "Impossible to find my library 'patchfns'."
+       echo "Check your install, or go to the right directory"
+       exit 1
+}
+
+usage()
+{
+       echo "Usage: fpatch patchname filename"
+       echo "       fpatch filename"
+       exit 1
+}
+
+if [ $# == 1 ]
+then
+       PATCH_NAME=$(top_patch)
+       FILENAME=$1
+elif [ $# == 2 ]
+then
+       PATCH_NAME=$(stripit $1)
+       FILENAME=$2
+else
+       usage
+fi
+
+
+if is_applied_last $PATCH_NAME
+then
+       true
+else
+       if is_applied $PATCH_NAME
+       then
+               echo $PATCH_NAME is not the last-applied patch
+               exit 1
+       else
+               echo $PATCH_NAME >> $DB
+       fi
+fi
+
+if file_in_patch $FILENAME $PATCH_NAME
+then
+       echo File $FILENAME is already in patch $PATCH_NAME
+       exit 1
+fi
+
+install_file_in_patch $FILENAME $PATCH_NAME
+
diff --git a/lustre/kernel_patches/scripts/import_patch b/lustre/kernel_patches/scripts/import_patch
new file mode 100755 (executable)
index 0000000..f818f19
--- /dev/null
@@ -0,0 +1,102 @@
+#!/bin/sh
+
+. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
+       echo "Impossible to find my library 'patchfns'."
+       echo "Check your install, or go to the right directory"
+       exit 1
+}
+
+usage()
+{
+       echo "usage: import_patch [ -p prefix-pattern ] patchfile [...]" 1>&2
+       exit 1
+}
+
+XPATTERN=""
+if [ "$1" = "-p" ]
+then
+       XPATTERN="$2"
+       shift; 
+       shift;
+fi
+
+if [ "$1" = "" ]
+then
+       usage
+fi
+
+if [ ! -e applied-patches ]
+then
+       touch applied-patches
+fi
+
+mkdir -p patches || exit 1
+mkdir -p txt || exit 1
+mkdir -p pc || exit 1
+
+if [ ! -e ./series ]
+then
+       touch ./series
+       if [ "$?" != "0" ]
+       then
+               echo "Cannot create ./series" 1>&2
+               exit 1
+       fi
+fi
+
+if [ ! -w ./series ]
+then
+       echo "./series is not writable." 1>&2
+       exit 1
+fi
+
+PATTERN='s/^'"$XPATTERN"'//'
+for x in $* 
+do
+       if [ ! -r "$x" ]
+       then
+               echo "$x does not exist, skipping." 1>&2
+               continue
+       fi
+       patchname=`basename $x .bz2`
+       patchname=`basename $patchname .gz`
+       patchname=`basename $patchname .Z`
+       patchname=`basename $patchname .patch`
+       if is_applied $patchname
+       then
+               echo $patchname is currently applied
+               exit 1
+       fi
+       if [ "$XPATTERN" != "" ]
+       then
+               patchname=`echo $patchname | sed -e "$PATTERN"`
+       fi
+       pname=$P/patches/"$patchname".patch
+       if [ -r "$pname" ]
+       then
+               echo "$pname exists already, skipping." 1>&2
+               continue
+       fi
+       case "$x" in
+       *.bz2) 
+               bunzip2 < "$x" > "$pname"
+               ;;
+       *.gz)
+               gunzip < "$x" > "$pname"
+               ;;
+       *.Z)    zcat < "$z" > "$pname"
+               ;;
+       *)      
+               cat "$x" > "$pname" || continue 
+               ;;
+       esac
+       echo "$patchname".patch >> series
+       pcpatch "$pname"
+       extract_description < "$pname" >$P/txt/"$patchname".txt
+       grep '^[(]undescribed patch[)]$' < $P/txt/"$patchname".txt > /dev/null
+       if [ "$?" = "0" ]
+       then
+               echo "Warning: $patchname has no description." 1>&2
+       fi
+done
+
diff --git a/lustre/kernel_patches/scripts/inpatch b/lustre/kernel_patches/scripts/inpatch
new file mode 100755 (executable)
index 0000000..edb2c20
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
+       echo "Impossible to find my library 'patchfns'."
+       echo "Check your install, or go to the right directory"
+       exit 1
+}
+
+usage()
+{
+       echo "Usage: inpatch"
+       exit 1
+}
+
+if [ $# != 0 ]
+then
+       usage
+fi
+
+if [ -e $DB ]
+then
+       TOP_PATCH=$(top_patch)
+       if [ x$TOP_PATCH != x ]
+       then
+               cat $P/pc/$TOP_PATCH.pc
+       fi
+fi
diff --git a/lustre/kernel_patches/scripts/linus-patch b/lustre/kernel_patches/scripts/linus-patch
new file mode 100755 (executable)
index 0000000..290b9cf
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh
+#
+# Grab a patch frmo kernel.org, install it.
+#
+# Usage: linus-patch http://www.kernel.org/pub/linux/kernel/people/dwmw2/bk-2.5/cset-1.786.152.7-to-1.798.txt.gz
+#
+
+. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
+       echo "Impossible to find my library 'patchfns'."
+       echo "Check your install, or go to the right directory"
+       exit 1
+}
+
+poppatch 999 || die poppatch
+wget $1 || die wget
+FILE=$(basename $1)
+gzip -d < $FILE > $P/patches/linus.patch
+pcpatch linus || die pcpatch
+(
+       echo DESC
+       echo $FILE
+       echo EDESC
+       echo
+       echo $FILE
+) > $P/txt/linus.txt
+rm $FILE
diff --git a/lustre/kernel_patches/scripts/mpatch b/lustre/kernel_patches/scripts/mpatch
new file mode 100755 (executable)
index 0000000..16d4eb7
--- /dev/null
@@ -0,0 +1,101 @@
+#!/bin/sh
+
+. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
+       echo "Impossible to find my library 'patchfns'."
+       echo "Check your install, or go to the right directory"
+       exit 1
+}
+
+usage()
+{
+       echo "Usage: mpatch patchname [output_dir]"
+       exit 1
+}
+
+doit()
+{
+       echo $* 1>&2
+       $* || {
+               echo oops
+               exit 1 
+       }
+}
+
+epoch()
+{
+#      doit touch -t 7001011000.00 $1
+       doit touch -t 7001010000.00 $1
+}
+
+dirfor()
+{
+       dir=$(dirname $1)
+       if [ ! -d $dir ]
+       then
+               doit mkdir -p $dir
+               RMDIRS="$RMDIRS $dir"
+       fi
+}
+
+if [ $# == 0 ]
+then
+       usage
+fi
+
+PATCH_NAME=$(stripit $1)
+OUTPUT_DIR=$2
+
+FILES=$(cat $P/pc/$PATCH_NAME.pc)
+OUT=$P/patches/$PATCH_NAME.patch
+TMPOUT=$(mktemp /tmp/patch-$PATCH_NAME-XXXXXX)
+TXT=$P/txt/$PATCH_NAME.txt
+OLDDIR=$(basename $(/bin/pwd))
+NEWDIR=$OLDDIR-$LOGNAME
+
+if is_applied_last $PATCH_NAME
+then
+       true
+else
+       echo $PATCH_NAME is not the last-applied patch
+       exit 1
+fi
+
+doit rm -f $OUT
+echo "Placing patch in " $OUT
+
+if [ -e $TXT -a -s $TXT ]
+then
+       echo >> $OUT
+       body $TXT >> $OUT
+       echo >> $OUT
+       echo >> $OUT
+else
+       echo "**** No patch description for $PATCH_NAME ****"
+fi
+
+rm -f $TMPOUT
+
+for file in $FILES
+do
+       OLD_FILE="$file"~"$PATCH_NAME"
+       if [ ! -e $OLD_FILE ]
+       then
+               OLD_FILE=/dev/null
+       fi
+       NEW_FILE=$file
+       XDIFF_OPTS=""
+       if [ ! -e $NEW_FILE ]
+       then
+               NEW_FILE=/dev/null
+               XDIFF_OPTS="-L $file"
+       fi
+
+       echo diff -puN $XDIFF_OPTS $DIFF_OPTS $OLD_FILE $NEW_FILE
+       diff -puN $XDIFF_OPTS $DIFF_OPTS $OLD_FILE $NEW_FILE | p0-2-p1 $OLDDIR $NEWDIR >> $TMPOUT
+done
+diffstat -p1 $TMPOUT >> $OUT 2>/dev/null
+echo >> $OUT
+cat $TMPOUT >> $OUT
+echo >> $OUT
+echo "_" >> $OUT
+rm -f $TMPOUT
diff --git a/lustre/kernel_patches/scripts/new-kernel b/lustre/kernel_patches/scripts/new-kernel
new file mode 100755 (executable)
index 0000000..2b065a6
--- /dev/null
@@ -0,0 +1,82 @@
+#!/bin/sh
+
+usage()
+{
+       echo "Usage: new-kernel linux-2.4.2-pre2 linux-2.4.3-pre3 linux-2.4.3 patch.gz cvs-dir"
+       exit 1
+}
+
+wantdir()
+{
+       if [ x$1 = x ]
+       then
+               usage
+       fi
+       if [ ! -d $1 ]
+       then
+               echo "directory $1 does not exist"
+               usage
+       fi
+}
+
+wantfile()
+{
+       if [ x$1 = x ]
+       then
+               usage
+       fi
+       if [ ! -f $1 ]
+       then
+               echo "file $1 does not exist"
+               usage
+       fi
+}
+
+doit()
+{
+       echo $* 1>&2
+       $* || {
+               echo oops
+               exit 1 
+       }
+}
+
+
+CURRENT_KERNEL=$1
+NEXT_KERNEL=$2
+BASE_KERNEL=$3
+PATCH_FILE=$4
+CVS_DIR=$5
+
+TEMP_PATCH=$(mktemp /tmp/patch-XXXXXX)
+MY_DIFF="$CURRENT_KERNEL"--"$NEXT_KERNEL"
+
+wantdir $CURRENT_KERNEL
+wantdir $BASE_KERNEL
+wantdir $CVS_DIR
+wantfile $PATCH_FILE
+
+doit rm -rf $NEXT_KERNEL
+doit cp -a $BASE_KERNEL $NEXT_KERNEL
+doit rm -f $TEMP_PATCH
+doit gunzip < $PATCH_FILE > $TEMP_PATCH
+cd $NEXT_KERNEL
+doit patch -p1 --dry-run -i $TEMP_PATCH
+doit patch -p1 -s -i $TEMP_PATCH
+echo cd ..
+cd ..
+
+echo diff -uNrp $CURRENT_KERNEL $NEXT_KERNEL
+diff -uNrp $CURRENT_KERNEL $NEXT_KERNEL > $MY_DIFF
+
+echo cd $CVS_DIR
+cd $CVS_DIR
+doit patch -p1 --dry-run -s -i ../$MY_DIFF
+doit patch -p1 -s -i ../$MY_DIFF
+cvs-take-patch ../$MY_DIFF
+cvs commit -m "'doing $NEXT_KERNEL'"
+cvs update -ko -d -P
+
+TAG=$(echo $NEXT_KERNEL | sed -e 's@\.@_@g')
+cvs tag $TAG
+rm -f $TEMP_PATCH
diff --git a/lustre/kernel_patches/scripts/p0-2-p1 b/lustre/kernel_patches/scripts/p0-2-p1
new file mode 100755 (executable)
index 0000000..266c698
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+#
+# Usage: p0-2-p1 olddir newdir
+#
+OLDDIR=$1
+NEWDIR=$2
+
+sed -e "s/^--- \([^\/].*\)/--- $OLDDIR\/\1/" |
+sed -e "s/^+++ \([^\/].*\)/+++ $NEWDIR\/\1/"
+
diff --git a/lustre/kernel_patches/scripts/p_diff b/lustre/kernel_patches/scripts/p_diff
new file mode 100755 (executable)
index 0000000..1ad3e09
--- /dev/null
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+#
+# Bring up a patched file in diff.  We show the diffs
+# in the topmost patch, unless it was specified
+#
+
+. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
+       echo "Impossible to find my library 'patchfns'."
+       echo "Check your install, or go to the right directory"
+       exit 1
+}
+
+usage()
+{
+       echo "Usage: pdiff [patchname] filename"
+       echo "       pdiff [patchname] -"
+       exit 1
+}
+
+if [ $# == 1 ]
+then
+       PATCH_NAME=$(top_patch)
+       FILENAME=$1
+elif [ $# == 2 ]
+then
+       PATCH_NAME=$(stripit $1)
+       FILENAME=$2
+else
+       usage
+fi
+
+if ! is_applied $PATCH_NAME
+then
+       echo $PATCH_NAME is not applied
+       exit 1
+fi
+
+doit()
+{
+       filename=$1
+       unpatched_file=$filename"~"$PATCH_NAME
+       need_file_there $filename
+       if [ -e $unpatched_file ]
+       then
+               diff -u $unpatched_file $filename
+       else
+               echo pdiff: $filename appears to not be in $PATCH_NAME
+       fi
+}
+
+if [ x"$FILENAME" = "x-" ]
+then
+       FILENAME=$(cat $P/pc/$PATCH_NAME.pc)
+fi
+
+for i in $FILENAME
+do
+       doit $i
+done
diff --git a/lustre/kernel_patches/scripts/patchdesc b/lustre/kernel_patches/scripts/patchdesc
new file mode 100755 (executable)
index 0000000..9a886fd
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
+       echo "Impossible to find my library 'patchfns'."
+       echo "Check your install, or go to the right directory"
+       exit 1
+}
+
+desc1()
+{
+       PATCH=$(stripit $1)
+       TXT=$P/txt/$PATCH.txt
+       echo $PATCH.patch
+       desc < $TXT
+       echo
+}
+
+for i in $*
+do
+       desc1 $i
+done
diff --git a/lustre/kernel_patches/scripts/patchfns b/lustre/kernel_patches/scripts/patchfns
new file mode 100644 (file)
index 0000000..b6cc468
--- /dev/null
@@ -0,0 +1,239 @@
+DB=applied-patches
+
+#
+# Work out where the user's pc/, patch/ and txt/ directories live.
+#
+# If the user specified PATCHSCRIPTS in environment then use that (it's
+# probably a relative path)
+#
+# If there is a directory ./patch-scripts then use that
+#
+# Otherwise use "."
+#
+
+if [ x$PATCHSCRIPTS != x ]
+then
+       P=$PATCHSCRIPTS
+elif [ -d ./patch-scripts ]
+then
+       P=./patch-scripts
+elif [ -d ./patches ]
+then
+       P=.
+else
+       echo "could not locate your pc/ and patches/ directories"
+       exit 1
+fi
+
+top_patch()
+{
+       tail -1 $DB
+}
+
+die()
+{
+       echo error: $*
+       exit 1
+}
+
+is_numeric()
+{
+       if echo $1 | egrep '^[0-9]*$' > /dev/null
+       then
+               return 0
+       fi
+       return 1
+}
+
+is_applied_last()
+{
+       name="$(stripit $1)"
+       top_patch >$DB.1
+       if grep "^$name$" "$DB.1" > /dev/null 2>&1
+       then
+               rm $DB.1
+               return 0
+       else
+               rm $DB.1
+               return 1
+       fi
+}
+
+is_applied()
+{
+       name=$(stripit "$1")
+       if grep "^$name$" "$DB" > /dev/null 2>&1
+       then
+               return 0
+       else
+               return 1
+       fi
+}
+
+can_apply()
+{
+       if patch -p1 --dry-run -i "$1" -f
+       then
+               return 0
+       else
+               return 1
+       fi
+}
+
+can_remove()
+{
+       if patch -R -p1 --dry-run -i $P/patches/"$1".patch -f
+       then
+               return 0
+       else
+               return 1
+       fi
+}
+
+remove_from_db()
+{
+       tmpfile=$(mktemp /tmp/p_XXXXXX)
+       name="$1"
+       sed -e "/^$name$/d" < "$DB" > $tmpfile
+       mv $tmpfile "$DB"
+}
+
+stripit()
+{
+       ret=$(basename $1)
+       ret=$(echo $ret | sed -e 's/\.patch$//')
+       ret=$(echo $ret | sed -e 's/\.pc$//')
+       ret=$(echo $ret | sed -e 's/\.txt$//')
+       echo $ret
+}
+
+top_is_current()
+{
+       patch_name=$(top_patch)
+       if [ x$patch_name == x ]
+       then
+               return 1
+       else
+               patch_file=$P/patches/"$patch_name".patch
+               files=$(cat $P/pc/$patch_name.pc)
+               for file in $files
+               do
+                       if [ $file -nt $patch_file ]
+                       then
+                               echo $file newer than $patch_file
+                               return 0
+                       fi
+               done
+       fi
+       return 1
+}
+
+need_top_current()
+{
+       if top_is_current
+       then
+               echo "Error: Top patch is not up-to-date"
+               exit 1
+       fi
+}
+
+warn_top_current()
+{
+       if top_is_current
+       then
+               echo "Warning: Top patch is not up-to-date"
+       fi
+}
+
+file_in_patch()
+{
+       file=$1
+       patch=$2
+
+       if [ -e $P/pc/$patch.pc ]
+       then
+               if grep "^"$file"$" $P/pc/$patch.pc > /dev/null
+               then
+                       return 0
+               fi
+       fi
+       return 1
+}
+
+# copy_file_to_bup filename patchname
+copy_file_to_bup()
+{
+       file=$1
+       patch=$2
+       bup="$file"~"$patch"
+
+       if [ -e $bup ]
+       then
+               echo "Cannot install file $file in patch $patch: backup $bup exists"
+               exit 1
+       fi
+
+       if [ -e $file ]
+       then
+               cp $file "$file"~"$patch"
+       else
+               echo "file $file appears to be newly added"
+       fi
+}
+
+install_file_in_patch()
+{
+       file=$1
+       patch=$2
+
+       copy_file_to_bup $file $patch
+       echo $file >> $P/pc/$patch.pc
+#      touch $P/txt/$patch.txt
+}
+
+need_file_there()
+{
+       if [ ! -e $1 ]
+       then
+               echo "File $1 does not exist"
+               exit 1
+       fi
+}
+
+desc()
+{
+       state=0
+       while read x
+       do
+               if [ x"$x" = xDESC ]
+               then
+                       state=1
+               elif [ x"$x" = xEDESC ]
+               then
+                       state=0
+               elif [ $state = 1 ]
+               then
+                       echo "  $x"
+               fi
+       done
+}
+
+body()
+{
+       file=$1
+
+       did_stuff=0
+       while read x
+       do
+               if [ x"$x" = xEDESC ]
+               then
+                       cat
+                       did_stuff=1
+               fi
+       done < $file
+
+       if [ $did_stuff = 0 ]
+       then
+               cat $file
+       fi
+}
diff --git a/lustre/kernel_patches/scripts/pcpatch b/lustre/kernel_patches/scripts/pcpatch
new file mode 100755 (executable)
index 0000000..fa53385
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
+       echo "Impossible to find my library 'patchfns'."
+       echo "Check your install, or go to the right directory"
+       exit 1
+}
+
+usage()
+{
+       echo "pcpatch: recreate the pc file from patches/{patchname}.patch"
+       exit 1
+}
+
+doit()
+{
+       echo $* 1>&2
+       $* || {
+               echo oops
+               exit 1 
+       }
+}
+
+if [ $# != 1 -o "$1" = "help" ]
+then
+       usage
+fi
+PATCH=$1
+PATCH_NAME=$(stripit $PATCH)
+PC=$P/pc/$PATCH_NAME.pc
+
+if [ ! -e $P/patches/$PATCH_NAME.patch ] 
+then
+       echo "$P/patches/$PATCH_NAME.patch does not exist"
+       exit 1
+fi
+
+if is_applied "$PATCH"
+then
+       echo $PATCH is applied!
+       exit 1
+fi
+
+touched-by-patch $P/patches/$PATCH_NAME.patch > $PC
+echo Recreated $PC
diff --git a/lustre/kernel_patches/scripts/poppatch b/lustre/kernel_patches/scripts/poppatch
new file mode 100755 (executable)
index 0000000..792cb9b
--- /dev/null
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
+       echo "Impossible to find my library 'patchfns'."
+       echo "Check your install, or go to the right directory"
+       exit 1
+}
+
+usage()
+{
+       echo "Usage: poppatch [npatches]"
+       exit 1
+}
+
+doit()
+{
+       echo $* 1>&2
+       $* || {
+               echo oops
+               exit 1 
+       }
+}
+
+if [ $# -gt 1 ]
+then
+       usage
+fi
+
+NR=1
+STOP_AT=""
+if [ $# -eq 1 ]
+then
+       if is_numeric $1
+       then
+               NR=$1
+       else
+               NR=1000
+               STOP_AT=$(stripit $1)
+       fi
+fi
+
+pop_one()
+{
+       TOP_PATCH=$(top_patch)
+       if [ x$TOP_PATCH == x ]
+       then
+               echo "no patches applied"
+               exit 0
+       else
+               popped_patch="$(top_patch)"
+               if ! rpatch $(top_patch)
+               then
+                       echo still at $(top_patch)
+                       exit 1
+               fi
+               echo
+       fi
+}
+
+for i in $(seq 1 $NR)
+do
+       pop_one
+       if [ x$STOP_AT != "x" ]
+       then
+               if [ $STOP_AT == $(toppatch) ]
+               then
+                       exit 0
+               fi
+       fi
+done
diff --git a/lustre/kernel_patches/scripts/prep-patch b/lustre/kernel_patches/scripts/prep-patch
new file mode 100755 (executable)
index 0000000..1d60ea9
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
+       echo "Impossible to find my library 'patchfns'."
+       echo "Check your install, or go to the right directory"
+       exit 1
+}
+
+if [ $# -ne 1 ]
+then
+       echo "Usage prep-patch patchname"
+       exit 1
+fi
+
+PATCHNAME=$(stripit $1)
+
+xcb -s 2 < $P/patches/$PATCHNAME.patch
+head -2 $P/txt/$PATCHNAME.txt | tail -1 | tr -d '\n' | xcb -s 1
diff --git a/lustre/kernel_patches/scripts/pstatus b/lustre/kernel_patches/scripts/pstatus
new file mode 100755 (executable)
index 0000000..f735d8d
--- /dev/null
@@ -0,0 +1,156 @@
+#!/bin/sh
+
+# print out patch status.  Usage: pstatus [ patchfile ... ]
+#
+# Stephen Cameron <steve.cameron@hp.com>
+#
+
+. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
+       echo "Impossible to find my library 'patchfns'."
+       echo "Check your install, or go to the right directory"
+       exit 1
+}
+
+if [ ! -f ./series ]
+then
+       echo "./series does not exist." 1>&2
+       exit 1
+fi
+
+if [ ! -d ./patches ]
+then
+       echo "Directory ./patches does not exist." 1>&2
+       exit 1
+fi
+
+
+PATCHLIST="$*"
+if [ "$PATCHLIST" = "" ]
+then
+       series_optimize=yes
+       PATCHLIST=`cat series | sed -e 's/[.]patch[     ]*$//'`
+       SORTSERIES=`mktemp /tmp/ser.XXXXXX` || exit 1 
+       SORTPATCHES=`mktemp /tmp/pat.XXXXXX` || exit 1
+       sed -e 's/^[    ]//' -e 's/[.]patch[    ]*$//' < series | \
+               sort > $SORTSERIES 
+       exists="`echo $P/patches/*.patch 2>/dev/null`"
+       if [ "$exists" != "$P/patches/*.patch" ]
+       then
+               ls -1 $P/patches/*.patch | sed -e 's/^.*\/patches\///' \
+                       -e 's/[.]patch[         ]*$//' | sort > $SORTPATCHES
+               PATCHLIST="$PATCHLIST"" `comm -1 -3 $SORTSERIES $SORTPATCHES`"
+       fi
+       rm -f $SORTPATCHES $SORTSERIES
+else
+       series_optimize=no
+fi
+
+NSERIES=`wc -l series | awk '{ print $1; }'`
+series=1
+for PATCH_NAME in $PATCHLIST 
+do
+       PATCH_NAME=$(stripit $PATCH_NAME)
+       # see if this patch even exists
+       if [ ! -f $P/patches/"$PATCH_NAME".patch ]
+       then
+               echo "$PATCH_NAME does not exist."
+               continue
+       fi
+       # see if this patch is applied
+       applied="-"
+       if [ -f applied-patches ]
+       then 
+               grep '^'"$PATCH_NAME"'$' applied-patches > /dev/null
+               if [ "$?" = "0" ]
+               then
+                       applied="a"
+               fi
+       fi
+
+       # figure the status of this patch, that is, 
+       # if it needs changelog, pcpatch, refpatch
+
+       stat=""
+       if [ ! -f $P/txt/"$PATCH_NAME".txt ]
+       then
+               stat="changelog "
+       fi
+       if [ ! -f $P/pc/"$PATCH_NAME".pc ]
+       then
+               stat="$stat""pcpatch "
+       elif [ "$applied" != '-' ]
+       then
+               rpatch=n
+
+               # for each file this patch touches
+               for y in `cat $P/pc/"$PATCH_NAME".pc`
+               do
+                       # is the patch adding the file?
+                       if [ ! -e "$y"'~'"$PATCH_NAME" -a -f "$y" ]
+                       then
+                               # file is newer than the patch?
+                               if [ "$y" -nt $P/patches/"$PATCH_NAME".patch ]
+                               then
+                                       rpatch=y
+                                       stat="$stat""refpatch "
+                                       break
+                               fi
+                       else
+                               # modified file is newer than the patch?
+                               if [ "$y"'~'"$PATCH_NAME" -nt \
+                                       $P/patches/"$PATCH_NAME".patch ]
+                               then
+                                       rpatch=y
+                                       stat="$stat""refpatch "
+                                       break
+                               fi
+                               if [ "`toppatch`" = "$PATCH_NAME" -a \
+                                       "$y" -nt $P/patches/"$PATCH_NAME".patch ]
+                               then
+                                       # toppatch, so check if the file 
+                                       # is newer than the patch?
+                                       rpatch=y
+                                       stat="$stat""refpatch "
+                                       break
+                               fi
+                       fi
+               done
+       fi
+       # check if they changed the changelog recently
+       if [ "$rpatch" = "n" -a -f $P/txt/"$PATCH_NAME".txt \
+               -a $P/txt/"$PATCH_NAME".txt -nt \
+               $P/patches/"$PATCH_NAME".patch ]
+       then
+               rpatch=y
+               stat="$stat""refpatch "
+       fi
+       if [ "$stat" != "" ]
+       then
+               stat="Needs ""$stat"
+       fi
+
+       if [ "$series_optimize" != "yes" ]
+       then
+               # have to find the series number the hard way.
+               series=`grep -n '^'"$PATCH_NAME"'\.patch$' series |\
+                       awk -F: '{ printf "%d", $1}' `
+               if [ "$series" = "" ]
+               then
+                       series="?"
+               fi
+       fi
+
+       echo "$series":"$applied":"$PATCH_NAME $stat"
+
+       if [ "$series_optimize" = "yes" ]
+       then
+               if [ "$series" != "?" ]
+               then
+                       series=`expr $series + 1`
+                       if [ $series -gt $NSERIES ]
+                       then 
+                               series="?"
+                       fi
+               fi
+       fi
+done 
diff --git a/lustre/kernel_patches/scripts/ptkdiff b/lustre/kernel_patches/scripts/ptkdiff
new file mode 100755 (executable)
index 0000000..97c9982
--- /dev/null
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+#
+# Bring up a patched file in tkdiff.  We show the diffs
+# in the topmost patch, unless it was specified
+#
+
+. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
+       echo "Impossible to find my library 'patchfns'."
+       echo "Check your install, or go to the right directory"
+       exit 1
+}
+
+usage()
+{
+       echo "Usage: ptkdiff filename ..."
+       echo "       ptkdiff -"
+       exit 1
+}
+
+PATCH_NAME=$(top_patch)
+
+doit()
+{
+       filename=$1
+       unpatched_file=$filename"~"$PATCH_NAME
+       need_file_there $filename
+       if [ -e $unpatched_file ]
+       then
+               tkdiff $unpatched_file $filename
+       else
+               echo ptkdiff: $filename appears to not be in $PATCH_NAME
+       fi
+}
+
+if [ x"$1" = "x-" ]
+then
+       FILENAME=$(cat $P/pc/$PATCH_NAME.pc)
+else
+       FILENAME="$*"
+fi
+
+for i in $FILENAME
+do
+       doit $i &
+done
diff --git a/lustre/kernel_patches/scripts/pushpatch b/lustre/kernel_patches/scripts/pushpatch
new file mode 100755 (executable)
index 0000000..018716d
--- /dev/null
@@ -0,0 +1,84 @@
+#!/bin/sh
+
+#
+# Add next patch in series
+#
+
+. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
+       echo "Impossible to find my library 'patchfns'."
+       echo "Check your install, or go to the right directory"
+       exit 1
+}
+
+usage()
+{
+       echo "Usage: pushpatch [npatches]"
+       exit 1
+}
+
+opt_force=0
+
+for i in $*
+do
+       case "$i" in
+       -f)
+               opt_force=1;;
+       *)
+               if [ -n "$NR" -o -n "$STOP_AT" ]
+               then
+                       usage
+               fi
+               if is_numeric $i
+               then
+                       NR=$i
+               else
+                       NR=1000
+                       STOP_AT=$(stripit $i)
+               fi;;
+       esac
+done
+
+[ $opt_force = 1 ] && force="-f"
+
+SERIES=series
+
+if [ ! -e $SERIES ]
+then
+       echo 'File "series" not found'
+       exit 1
+fi
+
+push_one()
+{
+       top=$(toppatch)
+       if [ x"$top" == x ]
+       then
+               todo=$(head -1 $SERIES)
+       else
+               last_in_series=$(stripit $(tail -1 $SERIES))
+               if [ $last_in_series == $top ]
+               then
+                       echo "Series fully applied.  Ends at $top"
+                       exit 0
+               fi
+               todo=$(grep -C1 "^$top\.patch" $SERIES | tail -1)
+               if [ x$todo = x ]
+               then
+                       todo=$(head -1 $SERIES)
+               fi
+       fi
+
+       apatch $force $todo
+}
+
+for i in $(seq 1 $NR)
+do
+       push_one
+       if [ x$STOP_AT != "x" ]
+       then
+               if [ $STOP_AT == $(toppatch) ]
+               then
+                       exit 0
+               fi
+       fi
+done
diff --git a/lustre/kernel_patches/scripts/refpatch b/lustre/kernel_patches/scripts/refpatch
new file mode 100755 (executable)
index 0000000..88f3caf
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
+       echo "Impossible to find my library 'patchfns'."
+       echo "Check your install, or go to the right directory"
+       exit 1
+}
+
+usage()
+{
+       echo "Usage: refpatch"
+       exit 1
+}
+
+doit()
+{
+       echo $* 1>&2
+       $* || {
+               echo oops
+               exit 1 
+       }
+}
+
+if [ $# != 0 ]
+then
+       usage
+fi
+
+TOP_PATCH=$(top_patch)
+mpatch $* $(top_patch)
+echo "Refreshed $TOP_PATCH"
diff --git a/lustre/kernel_patches/scripts/removed-by-patch b/lustre/kernel_patches/scripts/removed-by-patch
new file mode 100755 (executable)
index 0000000..ff12970
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh
+# Extract names of new files from a patch, print them out
+
+PATCHFILE=$1
+case "$PATCHFILE" in
+*.gz) CMD="gzip -d < $PATCHFILE";;
+*)    CMD="cat $PATCHFILE";;
+esac
+
+TMP=$(mktemp /tmp/rbp-XXXXXX)
+
+eval $CMD | egrep '^\+\+\+.*1970|\+\+\+.*1969' > $TMP
+sed -e 's@[^/]*/\([^   ]*\).*@\1@' < $TMP | sed -e 's@^linux/@@' | sort
+rm -f $TMP
diff --git a/lustre/kernel_patches/scripts/rename-patch b/lustre/kernel_patches/scripts/rename-patch
new file mode 100755 (executable)
index 0000000..8334f1e
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
+       echo "Impossible to find my library 'patchfns'."
+       echo "Check your install, or go to the right directory"
+       exit 1
+}
+OLD=$(stripit $1)
+NEW=$(stripit $2)
+
+mv $P/pc/$OLD.pc $P/pc/$NEW.pc
+mv $P/patches/$OLD.patch $P/patches/$NEW.patch
+mv $P/txt/$OLD.txt $P/txt/$NEW.txt
+
+cvs remove $P/pc/$OLD.pc
+cvs remove $P/patches/$OLD.patch
+cvs remove $P/txt/$OLD.txt
+
+cvs add $P/pc/$NEW.pc
+cvs add $P/patches/$NEW.patch
+cvs add $P/txt/$NEW.txt
diff --git a/lustre/kernel_patches/scripts/rolled-up-patch b/lustre/kernel_patches/scripts/rolled-up-patch
new file mode 100755 (executable)
index 0000000..52676dc
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
+       echo "Impossible to find my library 'patchfns'."
+       echo "Check your install, or go to the right directory"
+       exit 1
+}
+
+usage()
+{
+       echo "Usage: rolled-up-patch"
+       exit 1
+}
+
+if [ $# != 0 ]
+then
+       usage
+fi
+
+RUP=$(mktemp /tmp/rup-XXXXXX)
+rm -f $RUP
+
+for i in $(cat applied-patches)
+do
+       patch_name=$(stripit $i)
+       cat $P/pc/$patch_name.pc
+done | sort | uniq > $RUP
+
+kdiff $(cat $RUP)
+rm -f $RUP
diff --git a/lustre/kernel_patches/scripts/rpatch b/lustre/kernel_patches/scripts/rpatch
new file mode 100755 (executable)
index 0000000..42e1533
--- /dev/null
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
+       echo "Impossible to find my library 'patchfns'."
+       echo "Check your install, or go to the right directory"
+       exit 1
+}
+
+do_remove()
+{
+       if patch -R -p1 -s -i $P/patches/"$1".patch
+       then
+               true
+       else
+               echo SOMETHING WENT WRONG
+               exit 1
+       fi
+}
+
+kill_old_ones()
+{
+       FILES=$(cat $P/pc/$1.pc)
+       for file in $FILES
+       do
+               rm -f "$file"~"$1"
+       done
+}
+
+usage()
+{
+       echo "Usage: rpatch patchname"
+       exit 1
+}
+
+if [ $# == 0 ]
+then
+       usage
+fi
+
+PATCH_NAME=$(stripit $1)
+
+warn_top_current
+
+if is_applied "$PATCH_NAME"
+then
+       if can_remove "$PATCH_NAME"
+       then
+               do_remove "$PATCH_NAME"
+               kill_old_ones "$PATCH_NAME"
+               remove_from_db "$PATCH_NAME"
+       else
+               echo "$PATCH_NAME" does not remove cleanly
+               exit 1
+       fi
+else
+       echo "$PATCH_NAME" is not applied
+       exit 1
+fi
+
+top=$(top_patch)
+if [ x"$top" == x ]
+then
+       msg="no patches applied"
+else
+       msg="now at $top"
+fi
+
+echo Removed $PATCH_NAME, $msg
+
diff --git a/lustre/kernel_patches/scripts/split-patch b/lustre/kernel_patches/scripts/split-patch
new file mode 100755 (executable)
index 0000000..08ce431
--- /dev/null
@@ -0,0 +1,29 @@
+#!/usr/bin/perl -w
+$out = "";
+while (<>) {
+       next if (/^Only/);
+       next if (/^Binary/);
+       if (/^diff/ || /^Index/) {
+               if ($out) {
+                       close OUT;
+               }
+               (@out) = split(' ', $_);
+               shift(@out) if (/^diff/);
+               $out = pop(@out);
+               $out =~ s:/*usr/:/:;
+               $out =~ s:/*src/:/:;
+               $out =~ s:^/*linux[^/]*::;
+               $out =~ s:\(w\)::;
+               next if ($out eq "");
+               $out = "/var/tmp/patches/$out";
+               $dir = $out;
+               $dir =~ s:/[^/]*$::;
+               print STDERR "$out\n";
+               system("mkdir -p $dir");
+               open(OUT, ">$out") || die("cannot open $out");
+       }
+       if ($out) {
+               print OUT $_;
+       }
+}
+
diff --git a/lustre/kernel_patches/scripts/tag-series b/lustre/kernel_patches/scripts/tag-series
new file mode 100755 (executable)
index 0000000..17f3dfe
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+# tag-series tagname series-file-name
+#
+# Does a `cvs tag tagname' of all the .pc, .txt and .patch files mentioned
+# in series-file-name.  Also tags series-file-name.
+#
+
+. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
+       echo "Impossible to find my library 'patchfns'."
+       echo "Check your install, or go to the right directory"
+       exit 1
+}
+
+# tag_one tag patchname
+#
+tag_one()
+{
+       PN=$(stripit $2)
+       if [ -r $P/txt/$PN.txt ]
+       then
+               cvs tag $1 $P/pc/$PN.pc $P/patches/$PN.patch $P/txt/$PN.txt
+       else
+               cvs tag $1 $P/pc/$PN.pc $P/patches/$PN.patch
+       fi
+}
+
+if [ $# -ne 2 ]
+then
+       echo Usage: tag-series tagname series-file-name
+       exit 1
+fi
+
+TAG=$1
+SERIES=$2
+
+for p in $(cat $SERIES)
+do
+       tag_one $TAG $p
+done
+cvs tag $TAG $SERIES
diff --git a/lustre/kernel_patches/scripts/toppatch b/lustre/kernel_patches/scripts/toppatch
new file mode 100755 (executable)
index 0000000..6df239d
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
+       echo "Impossible to find my library 'patchfns'."
+       echo "Check your install, or go to the right directory"
+       exit 1
+}
+
+usage()
+{
+       echo "Usage: toppatch"
+       exit 1
+}
+
+if [ $# != 0 ]
+then
+       usage
+fi
+
+if [ -e $DB ]
+then
+       TOP_PATCH=$(top_patch)
+       if [ x$TOP_PATCH != x ]
+       then
+               echo $TOP_PATCH
+       fi
+fi
diff --git a/lustre/kernel_patches/scripts/touched-by-patch b/lustre/kernel_patches/scripts/touched-by-patch
new file mode 100755 (executable)
index 0000000..df5b387
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+# Extract names of new files from a patch, print them out
+
+PATCHFILE=$1
+case "$PATCHFILE" in
+*.gz) CMD="gzip -d < $PATCHFILE";;
+*)    CMD="cat $PATCHFILE";;
+esac
+
+TMP=$(mktemp /tmp/tbp-XXXXXX) || exit 1
+TMP2=$(mktemp /tmp/tbp2-XXXXXX) || exit 1
+
+eval $CMD | egrep '^\+\+\+ |^\-\-\- ' > $TMP
+
+cat $TMP | sed -e 's@[^/]*/\([^        ]*\).*@\1@' \
+        | grep -v '^dev\/null$' \
+        | sort \
+        | uniq \
+        > $TMP2
+
+rm -f $TMP
+grep < $TMP2 '^[+][+][+]' > /dev/null
+if [ "$?" = "0" ]
+then
+       echo "WARNING: $PATCHFILE appears to be -p0 form rather than -p1." 1>&2
+       echo "         Use "\'"p0-2-p1 . . < $PATCHFILE"\'" to fix" 1>&2
+       awk '{ print $2 }' < $TMP2
+else
+       cat $TMP2
+fi | grep -v '~'
+
+rm -f $TMP2
diff --git a/lustre/kernel_patches/scripts/unitdiff.py b/lustre/kernel_patches/scripts/unitdiff.py
new file mode 100755 (executable)
index 0000000..d19d5e7
--- /dev/null
@@ -0,0 +1,223 @@
+#!/usr/bin/python
+
+import sys
+import re
+import string
+
+#TODO
+# clean up rest/file
+# clean up +6 and like (assumptions). should be turned into 'find'
+# make regession tests for all cases (Only in, etc)
+
+try:
+        filename = sys.argv[1]
+except:
+        print 'requires a file name'
+        sys.exit(1)
+
+filefd = open(filename)
+file = filefd.read()
+filefd.close()
+
+rest = file
+pat = "(^(?:diff .*\n)?--- .*\n\+\+\+ .*)?\n@@ -(\d+),?(\d+)? \+(\d+),?(\d+)? @@|^(Only in .*)"
+startpat = re.compile(pat, re.M)
+
+pos = 0
+oldpos = 0
+filelen = len(rest)
+oldrest = ""
+while(1):
+        rexp = startpat.search(rest)
+        if not rexp:
+                break
+
+       if rexp.group(6):
+               print rexp.group(6)
+               rest = rest[rexp.end(6)+1:]
+               continue
+               
+       header = rexp.group(1)
+        orgfile_start = string.atoi(rexp.group(2))
+       if rexp.group(3):
+               orgfile_len = string.atoi(rexp.group(3))
+       else:
+               orgfile_len = -1
+        newfile_start = string.atoi(rexp.group(4))
+       if rexp.group(5):
+               newfile_len = string.atoi(rexp.group(5))
+       else:
+               newfile_len = -1
+        rest = rest[rexp.start(2):]
+        rest = rest[string.find(rest, "\n")+1:]
+
+       rexp2 = startpat.search(rest)
+       if rexp2:
+               if rexp2.start(6) != -1:
+                       oldrest = rest[rexp2.start(6)-1:]
+                       rest = rest[:rexp2.start(6)]
+               elif rexp2.start(1) == -1:
+                       oldrest = rest[rexp2.start(2)-5:]
+                       rest = rest[:rexp2.start(2)-4]
+               else:
+                       oldrest = rest[rexp2.start(1)-1:]
+                       rest = rest[:rexp2.start(1)]
+       else:
+               oldrest = rest
+
+#      pos = filelen - len(oldrest)
+#      if pos - oldpos > 100:
+#              sys.stderr.write(`pos`+'/'+`filelen`+'\n')
+#              oldpos = pos
+
+       first = 1
+       oldminuses = 0
+       oldplusses = 0
+       oldoffset = 0
+       while(1):
+               #erstat early line stuff med lookbehind paa {1,2}-dims
+               #nedenfor RAA
+               linepat = "^([^-+\n]*)\n?(((^[-+].*\n)|^(.*\n){1,2}(?=^[-+].*\n))+)(.*)\n?"
+               compat = re.compile(linepat, re.M)
+               rexp = compat.search(rest)
+               if not rexp:
+                       break
+
+               prematch = rexp.group(1)
+               match = rexp.group(2)
+               muddle = len(match)
+
+#              print rest
+#              print 'prematch ', rexp.start(1), rexp.end(1), prematch
+#              print 'match ---------'
+#              print match
+#              print 'match --------'
+
+               # dump unwanted early lines...
+               if match[0] != "+" and match[0] != "-":
+                       while(1):
+                               next = string.find(match, '\n')
+                               if next == -1:
+                                       break
+                               if match[next+1] == "+" or match[next+1] == "-":
+                                       prematch = match[:next]
+                                       match = match[next+1:]
+                                       break
+                               match = match[next+1:]
+
+
+#              print 'prematch ', rexp.start(1), rexp.end(1), len(prematch)
+#              print '('+prematch+')'
+#              if prematch == ' ':
+#                      print 'space'
+               muddle = muddle - len(match)
+
+               lines = string.count(match, "\n")
+               compat = re.compile("^-", re.M)
+               minuses = len(compat.findall(match))
+               compat = re.compile("^\+", re.M)
+               plusses = len(compat.findall(match))
+               orgsize = minuses + 2 + (lines - minuses - plusses)
+               newsize = plusses + 2 + (lines - minuses - plusses)
+
+               noeol = "^(\\\ No newline at end of file)$"
+               compnoeol = re.compile(noeol, re.M)
+               if compnoeol.search(match) or compnoeol.search(rexp.group(6)):
+                       orgsize = orgsize - 1
+                       newsize = newsize - 1
+                       
+               coherent = 0
+               if lines - plusses == 0:
+                       coherent = 1
+               elif lines - minuses == 0:
+                       coherent = 1
+
+               # RAA FIXME
+               if not len(prematch):#or len(prematch) == 1 and prematch == ' ':
+                       orgsize = orgsize -1
+                       newsize = newsize -1
+               if rexp.start(6) == rexp.end(6):
+                       orgsize = orgsize -1
+                       newsize = newsize -1
+
+#              print "lines in match: ", lines
+#              print "number of minuses: ", minuses
+#              print "number of plusses: ", plusses
+       
+               matchpos = rexp.start(2) + muddle
+               offset =  string.count(rest[:matchpos], "\n")
+
+#              print 'offset/oldoffset: ', offset,oldoffset
+#              print 'oldplusses/oldminuses: ', oldplusses, oldminuses
+#              print 'orgfile_start/newfile_start: ', orgfile_start, newfile_start
+
+               orgstart = orgfile_start + offset + oldoffset - oldplusses
+               newstart = newfile_start + offset - oldminuses + oldoffset
+
+               # RAA: Bwadr. Fix antagelse om prematch paa en anden
+               # maade
+               orgstartmod = 0
+               newstartmod = 0
+               if orgfile_start == 1 and not len(prematch):
+                       orgstartmod = 1
+               if newfile_start == 1 and not len(prematch):
+                       newstartmod = 1
+               if orgfile_start == 0 and orgfile_len == 0:
+                       orgstartmod = 1
+                       # RAA Hack!
+                       plusses = plusses + 1
+                       minuses = minuses +1
+               if newfile_start == 0 and newfile_len == 0:
+                       newstartmod = 1
+                       # RAA Hack!
+                       plusses = plusses + 1
+                       minuses = minuses +1
+               
+               if header and first:
+                       print header
+                       first = 0
+
+               # should the start(1) == 0 be orgstart == 1? RAA
+               if orgstart == 1 and newstart == 1 and plusses == 0 and coherent:
+                       print "@@ -"+`orgstart`+","+`orgsize`+" +"+`newstart`+" @@"
+                       print match[:string.rfind(match, "\n")]
+                       print rexp.group(6)
+               elif rexp.start(6) == rexp.end(6) and plusses == 0 and coherent:
+                       if orgstartmod:
+                               orgstart = orgstart + 1
+                       if newstartmod:
+                               newstart = newstart + 1
+                       print "@@ -"+`orgstart-1`+","+`orgsize`+" +"+`newstart-1`+" @@"
+                       print prematch
+                       print match[:string.rfind(match, "\n")]
+               elif orgstart == 1 and orgstart == 1 and minuses == 0 and coherent:
+                       print "@@ -"+`orgstart`+" +"+`newstart`+","+`newsize`+" @@"
+                       print match[:string.rfind(match, "\n")]
+                       print rexp.group(6)
+               elif rexp.start(6) == rexp.end(6) and minuses == 0 and coherent:
+                       if orgstartmod:
+                               orgstart = orgstart + 1
+                       if newstartmod:
+                               newstart = newstart + 1
+                       print "@@ -"+`orgstart-1`+" +"+`newstart-1`+","+`newsize`+" @@"
+                       print prematch
+                       print match[:string.rfind(match, "\n")]
+               else:
+                       if orgstartmod:
+                               orgstart = orgstart + 1
+                       if newstartmod:
+                               newstart = newstart + 1
+                       print "@@ -"+`orgstart-1`+","+`orgsize`+" +"+`newstart-1`+","+`newsize`+" @@"
+                       if len(prematch):
+                               print prematch
+                       print match[:string.rfind(match, "\n")]
+                       if rexp.start(6) != rexp.end(6):
+                               print rexp.group(6)
+       
+               rest = rest[rexp.end(6):]
+               oldminuses = minuses + oldminuses
+               oldplusses = plusses + oldplusses
+               oldoffset = oldoffset + offset + lines #include match()-lines
+
+
+       rest = oldrest
diff --git a/lustre/kernel_patches/series/rh-8.0 b/lustre/kernel_patches/series/rh-8.0
new file mode 100644 (file)
index 0000000..4c64ad2
--- /dev/null
@@ -0,0 +1,8 @@
+dev_read_only.patch
+exports.patch
+kmem_cache_validate.patch
+lustre_version.patch
+uml_check_get_page.patch
+uml_no_panic.patch
+vfs_intent.patch
+uml_compile_fixes.patch
diff --git a/lustre/kernel_patches/txt/dev_read_only.txt b/lustre/kernel_patches/txt/dev_read_only.txt
new file mode 100644 (file)
index 0000000..010cdb7
--- /dev/null
@@ -0,0 +1,3 @@
+DESC
+(undescribed patch)
+EDESC
diff --git a/lustre/kernel_patches/txt/exports.txt b/lustre/kernel_patches/txt/exports.txt
new file mode 100644 (file)
index 0000000..010cdb7
--- /dev/null
@@ -0,0 +1,3 @@
+DESC
+(undescribed patch)
+EDESC
diff --git a/lustre/kernel_patches/txt/kmem_cache_validate.txt b/lustre/kernel_patches/txt/kmem_cache_validate.txt
new file mode 100644 (file)
index 0000000..010cdb7
--- /dev/null
@@ -0,0 +1,3 @@
+DESC
+(undescribed patch)
+EDESC
diff --git a/lustre/kernel_patches/txt/lustre_version.txt b/lustre/kernel_patches/txt/lustre_version.txt
new file mode 100644 (file)
index 0000000..010cdb7
--- /dev/null
@@ -0,0 +1,3 @@
+DESC
+(undescribed patch)
+EDESC
diff --git a/lustre/kernel_patches/txt/uml_check_get_page.txt b/lustre/kernel_patches/txt/uml_check_get_page.txt
new file mode 100644 (file)
index 0000000..010cdb7
--- /dev/null
@@ -0,0 +1,3 @@
+DESC
+(undescribed patch)
+EDESC
diff --git a/lustre/kernel_patches/txt/uml_compile_fixes.txt b/lustre/kernel_patches/txt/uml_compile_fixes.txt
new file mode 100644 (file)
index 0000000..010cdb7
--- /dev/null
@@ -0,0 +1,3 @@
+DESC
+(undescribed patch)
+EDESC
diff --git a/lustre/kernel_patches/txt/uml_no_panic.txt b/lustre/kernel_patches/txt/uml_no_panic.txt
new file mode 100644 (file)
index 0000000..010cdb7
--- /dev/null
@@ -0,0 +1,3 @@
+DESC
+(undescribed patch)
+EDESC
diff --git a/lustre/kernel_patches/txt/vfs_intent.txt b/lustre/kernel_patches/txt/vfs_intent.txt
new file mode 100644 (file)
index 0000000..010cdb7
--- /dev/null
@@ -0,0 +1,3 @@
+DESC
+(undescribed patch)
+EDESC