Whamcloud - gitweb
file llobdstat.pl was initially added on branch b_devel.
[fs/lustre-release.git] / lustre / extN / Makefile.am
index 4e4785b..d1de59b 100644 (file)
 # This code is issued under the GNU General Public License.
 # See the file COPYING in this distribution
 
-DEFS:=-DEXPORT_SYMTAB
+DEFS=-DEXPORT_SYMTAB
 MODULE = extN
 modulefs_DATA = extN.o
 EXTRA_PROGRAMS = extN
 
-EXTNP = htree-ext3-2.4.18.diff linux-2.4.18ea-0.8.26.diff
-EXTNP+= ext3-2.4.18-ino_sb_macro.diff extN-misc-fixup.diff
+# NOTE: If you are not using a RedHat 12.5 or later kernel, then you need to
+#       apply the "fixes" patch first, as it fixes a number of bugs in ext3.
+#       It will be applied automatically by the extN build process, or you
+#       can apply it to the source kernel tree and fix ext3 also.  For chaos22
+#       (or other RH < 12.5 kernels) use the "chaos22" patch instead.
+EXTN_FIXES = patch-2.4.18-chaos22
+#EXTN_FIXES = ext3-2.4.18-fixes.diff
+EXTNP = htree-ext3-2.4.18.diff linux-2.4.18ea-0.8.26.diff ext3-2.4-ino_t.diff
+EXTNP+= ext3-2.4.18-ino_sb_macro.diff extN-misc-fixup.diff extN-noread.diff
+EXTNP+= extN-wantedi.diff extN-san.diff extN-2.4.18-ino_sb_fixup.diff
+#EXTNP+= extN-iget-debug.diff
 EXTNC = balloc.c bitmap.c dir.c file.c fsync.c ialloc.c inode.c ioctl.c
 EXTNC+= namei.c super.c symlink.c
-EXTNI = extN_fs.h extN_fs_i.h extN_fs_sb.h extN_jbd.h
+EXTNI = extN_fs.h extN_fs_i.h extN_fs_sb.h extN_jbd.h quotaops.h
 EXTN_EXTRA = include/linux/xattr.h include/linux/extN_xattr.h fs/extN/xattr.c
-extN_SOURCES = $(EXTNC) $(EXTNI) xattr.c # punch.c
+EXTN_EXTRA += include/linux/quotaops.h
+extN_SOURCES = $(EXTNC) xattr.c # punch.c
 extN_DEPENDENCIES = patch-stamp
-EXTRA_DIST = $(EXTNP) extN-2.4.18-ino_sb_fixup.diff extN-2.4.18-exports.diff
-DISTCLEANFILES = $(EXTNC) $(EXTNI) patch-stamp *.orig *.rej
-SUB=-e "s/ext3/extN/g" -e "s/EXT3/EXTN/g"
+EXTRA_DIST = $(EXTNP) $(EXTN_FIXES) \
+       ext3-largefile.diff extN-2.4.18-exports.diff \
+       ext3-use-after-free.diff ext3-unmount_sync.diff $(wildcard extN.patch-*)
+DISTCLEANFILES = -r $(extN_SOURCES) sed-stamp patch-stamp *.orig *.rej
+SUB=-e "s/ext3/extN/g" -e "s/EXT3/EXTN/g" -e "s/extern __inline__/static inline/"
+
+distclean:
+       cd .. && rm -f $(EXTN_EXTRA)
 
 include $(top_srcdir)/Rules
 
+# Following 2 vars are for buildind outside the source tree.
+extN_orig = $(top_builddir)/$(subdir)/extN.orig
+extN_include_orig = $(top_builddir)/$(subdir)/extN-include.orig
+
+# Create a fresh extN patch.
+# This is for when the patch-stamp target fails for your kernel.
+# Just edit the files until you like them, then do `make diff', and
+# it will create a specialized patch for your particular kernel.
+# Check it in, and the build should work for you without disrupting
+# the other developers.
+# Of course, the ideal is to merge changes so that the default patch
+# set works for nearly everybody.  This is mainly for damage control.
+
+diff:
+       $(RM) extN.patchT
+       l='$(EXTNC)'; for f in $$l; do                                        \
+          echo "$$f";                                                         \
+          (diff -u $(extN_orig)/$$f extN/$$f) >> extN.patchT;                 \
+          test $$? -le 1 || exit 1;                                           \
+       done
+       l='$(EXTNI)'; for f in $$l; do                                        \
+          echo "$$f";                                                         \
+          (diff -u $(extN_include_orig)/$$f $(top_srcdir)/include/linux/$$f)>>extN.patchT;\
+          test $$? -le 1 || exit 1;                                           \
+       done
+       l='$(EXTN_EXTRA)'; for f in $$l; do                                   \
+          f=`echo "$$f" | sed 's%^fs/%%'`;                                    \
+          echo "$$f";                                                         \
+          (cd $(top_srcdir) &&                                                \
+            diff -u /dev/null $$f) >> extN.patchT;                            \
+          test $$? -le 1 || exit 1;                                           \
+       done
+       mv -f extN.patchT $(top_builddir)/$(subdir)/extN.patch-$(RELEASE)
+       echo "Don't forget to add $(srcdir)/extN.patch-$(RELEASE) to CVS!"
+
+.PHONY: diff
+
+# Just do the SUB transformation on all our source files.
+sed-stamp:
+       $(RM) $@
+       rm -rf $(extN_orig) $(extN_include_orig)
+       mkdir $(extN_orig) $(extN_include_orig)
+       list='$(EXTNC)'; for f in $$list; do                                  \
+          echo "creating $(extN_orig)/$$f";                                   \
+          sed $(SUB) $(LINUX)/fs/ext3/$$f > $(extN_orig)/$$f;                 \
+       done
+       list='$(EXTNI)'; for i in $$list; do                                  \
+          s=`echo $$i | sed "s/extN/ext3/"`;                                  \
+          echo "creating $(extN_include_orig)/$$i";                           \
+          sed $(SUB) $(LINUX)/include/linux/$$s > $(extN_include_orig)/$$i;   \
+       done
+       echo timestamp > $@
+
+
 # Patch the kernel files with our ext3 patches.  We need to go through some
 # extra hoops because the include files are in a different tree and because
 # patch likes to make local copies of files with (sym)links when it is patching
 # them.  To avoid this, we copy/patch in the source dir instead of the build
 # dir (if they are different).
-patch-stamp: $(EXTNP)
-       test -e $(top_srcdir)/fs || ln -sf . $(top_srcdir)/fs
-       set -vx;\
-       list='$(EXTN_EXTRA)'; for f in $$list; do $(RM) $(top_srcdir)/$$f; done
-       set -vx;\
-       list='$(EXTNC)'; for f in $$list; do                                  \
-       sed $(SUB) $(LINUX)/fs/ext3/$$f > $(top_srcdir)/fs/extN/$$f;          \
-       done
-       set -vx;\
-       list='$(EXTNI)'; for i in $$list; do                                  \
-       s=`echo $$i | sed "s/extN/ext3/"`;                                    \
-       sed $(SUB) $(LINUX)/include/linux/$$s >                               \
-               $(top_srcdir)/include/linux/$$i;                              \
-       done
-       set -vx;\
-       list='$(EXTNP)'; for p in $$list; do                                  \
-       sed $(SUB) $(srcdir)/$$p | (cd $(top_srcdir); patch -p1);             \
-       done
-       (cd $(top_srcdir); patch -p1) < $(srcdir)/extN-2.4.18-ino_sb_fixup.diff
-       -(cd $(top_srcdir); patch -p1) < $(srcdir)/extN-2.4.18-exports.diff
-       echo timestamp > patch-stamp
+# We also want to preserve the pristine transformed files for the diff target.
+
+
+
+patch-stamp: sed-stamp $(EXTNP)
+       test -e $(top_builddir)/include/linux || mkdir -p $(top_builddir)/include/linux 
+       cp -a $(extN_orig)/* $(top_builddir)/$(subdir)
+       cp -a $(extN_include_orig)/* $(top_builddir)/include/linux
+       test -e $(top_builddir)/fs || ln -s . $(top_builddir)/fs
+       list='$(EXTN_EXTRA)'; for f in $$list; do $(RM) $(top_builddir)/$$f; done
+       if [ -f $(srcdir)/extN.patch-$(RELEASE) ]; then                       \
+         echo "applying patch $(srcdir)/extN.patch-$(RELEASE)";              \
+         (cd $(top_builddir) && patch -p0) < $(srcdir)/extN.patch-$(RELEASE);\
+       else                                                                  \
+         list='$(EXTNP)'; \
+         grep -q "err = extN_mark_inode_dirty" $(extN_orig)/namei.c ||       \
+           list="ext3-use-after-free.diff $$list";                           \
+         sed '/i_version/q' $(extN_orig)/namei.c | tail -2 |                 \
+           grep -q extN_mark_inode_dirty && list="$(EXTN_FIXES) $$list";     \
+         grep -q "if (do_sync_supers)" $(extN_orig)/super.c &&               \
+           list="ext3-unmount_sync.diff $$list";                             \
+         grep -q "ext3_journal_start(inode, 2)" $(extN_orig)/inode.c ||      \
+           list="ext3-largefile.diff $$list";                                \
+         grep -q "EXPORT_SYMBOL(extN_bread)" $(extN_orig)/super.c ||         \
+           list="$$list extN-2.4.18-exports.diff";                           \
+         for p in $$list; do                                                 \
+           echo "applying patch $$p";                                        \
+           sed $(SUB) $(srcdir)/$$p |                                        \
+             (cd $(top_builddir) && patch -p1) || exit $$?;                  \
+         done;                                                               \
+       fi
+       echo timestamp > $@
+
+
+
 
-$(EXTNC) $(EXTNI): patch-stamp
+$(extN_SOURCES) $(EXTNI) $(EXTN_EXTRA): patch-stamp
 
 # Don't distribute any patched files.
 dist-hook:
-       rm -f $(top_srcdir)/fs
-       list='$(EXTNC)'; for f in $$list; do rm -f $(distdir)/$$f; done
+       $(RM) $(top_srcdir)/fs
+       list='$(EXTNC)'; for f in $$list; do $(RM) $(distdir)/$$f; done
        list='$(EXTNI)'; for i in $$list; do                                  \
-               rm -f $(distdir)/../include/linux/$$i;                        \
+         $(RM) $(distdir)/../include/linux/$$i;                              \
        done
+       list='$(EXTN_EXTRA)'; for f in $$list; do $(RM) $(distdir)/../$$f; done