From 13fa1003e4f86b4d814d6259020618684784cbe7 Mon Sep 17 00:00:00 2001 From: girish Date: Thu, 8 Jan 2009 17:29:25 +0000 Subject: [PATCH] Add configure option to allow repackaging of e2fsprogs as ldiskfsprogs. (By Jim Garlick) b=17953 i=adilger i=girish.shilamkar --- build/autoconf/lustre-build.m4 | 42 ++++++++++++++++++++++++++++++ lustre/tests/acceptance-small.sh | 4 +-- lustre/tests/conf-sanity.sh | 18 ++++++------- lustre/tests/lfscktest.sh | 22 ++++++++-------- lustre/tests/sanity.sh | 2 +- lustre/tests/test-framework.sh | 11 ++++++-- lustre/utils/lr_reader.c | 12 ++++++--- lustre/utils/mkfs_lustre.c | 56 +++++++++++++++++++++++----------------- lustre/utils/mount_utils.c | 8 ++++-- 9 files changed, 120 insertions(+), 55 deletions(-) diff --git a/build/autoconf/lustre-build.m4 b/build/autoconf/lustre-build.m4 index 73707bb..2d7e6c5 100644 --- a/build/autoconf/lustre-build.m4 +++ b/build/autoconf/lustre-build.m4 @@ -276,6 +276,46 @@ AC_DEFUN([LB_DEFINE_LDISKFS_OPTIONS], ]) # +# LB_DEFINE_E2FSPROGS_NAMES +# +# Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package. +# +AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES], +[AC_ARG_WITH([ldiskfsprogs], + AC_HELP_STRING([--with-ldiskfsprogs], + [use alternate names for ldiskfs-enabled e2fsprogs]), + [],[withval='no']) + +if test x$withval = xyes ; then + AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package]) + E2FSPROGS="ldiskfsprogs" + MKE2FS="mkfs.ldiskfs" + DEBUGFS="debug.ldiskfs" + TUNE2FS="tune.ldiskfs" + E2LABEL="label.ldiskfs" + DUMPE2FS="dump.ldiskfs" + E2FSCK="fsck.ldiskfs" + AC_MSG_RESULT([enabled]) +else + E2FSPROGS="e2fsprogs" + MKE2FS="mke2fs" + DEBUGFS="debugfs" + TUNE2FS="tune2fs" + E2LABEL="e2label" + DUMPE2FS="dumpe2fs" + E2FSCK="e2fsck" + AC_MSG_RESULT([disabled]) +fi + AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package]) + AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program]) + AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program]) + AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program]) + AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program]) + AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program]) + AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program]) +]) + +# # LB_CONFIG_CRAY_XT3 # # Enable Cray XT3 features @@ -752,6 +792,8 @@ LB_PATH_SNMP LB_PATH_LDISKFS LB_PATH_LUSTREIOKIT +LB_DEFINE_E2FSPROGS_NAMES + LC_CONFIG_LIBLUSTRE LIBCFS_CONFIGURE LN_CONFIGURE diff --git a/lustre/tests/acceptance-small.sh b/lustre/tests/acceptance-small.sh index 7edce6f..fa4a14b 100755 --- a/lustre/tests/acceptance-small.sh +++ b/lustre/tests/acceptance-small.sh @@ -311,8 +311,8 @@ for NAME in $CONFIGS; do if [ -x /usr/sbin/lfsck ]; then bash lfscktest.sh else - log "$(e2fsck -V)" - log "SKIP: e2fsck does not support lfsck" + log "$($E2FSCK -V)" + log "SKIP: $E2FSCK does not support lfsck" fi LFSCK="done" fi diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index b4fd2a1..05e8049 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -426,7 +426,7 @@ test_16() { cleanup || return $? log "read the mode of OBJECTS and check if they has been changed properly" - EXPECTEDOBJECTSMODE=`do_facet $SINGLEMDS "debugfs -R 'stat OBJECTS' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"` + EXPECTEDOBJECTSMODE=`do_facet $SINGLEMDS "$DEBUGFS -R 'stat OBJECTS' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"` if [ "$EXPECTEDOBJECTSMODE" = "0777" ]; then log "Success:Lustre change the mode of OBJECTS correctly" @@ -448,7 +448,7 @@ test_17() { fi echo "Remove mds config log" - do_facet $SINGLEMDS "debugfs -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MDSDEV || return \$?" || return $? + do_facet $SINGLEMDS "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MDSDEV || return \$?" || return $? start_ost start_mds && return 42 @@ -501,7 +501,7 @@ test_18() { check_mount || return 41 echo "check journal size..." - local FOUNDSIZE=`do_facet mds "debugfs -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}'` + local FOUNDSIZE=`do_facet mds "$$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}'` if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M" else @@ -1380,8 +1380,8 @@ test_38() { # bug 14222 local dev=${SINGLEMDS}_dev local MDSDEV=${!dev} - do_facet $SINGLEMDS "debugfs -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV" - do_facet $SINGLEMDS "debugfs -w -R \\\"rm lov_objid\\\" $MDSDEV" + do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV" + do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV" do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.orig" # check create in mds_lov_connect @@ -1391,7 +1391,7 @@ test_38() { # bug 14222 [ $V ] && log "verifying $DIR/$tdir/$f" diff -q $f $DIR/$tdir/$f || ERROR=y done - do_facet $SINGLEMDS "debugfs -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\" $MDSDEV" + do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\" $MDSDEV" do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new" [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true @@ -1400,8 +1400,8 @@ test_38() { # bug 14222 stop_mds do_facet $SINGLEMDS dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1 - do_facet $SINGLEMDS "debugfs -w -R \\\"rm lov_objid\\\" $MDSDEV" - do_facet $SINGLEMDS "debugfs -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV " + do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV" + do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV " start_mds mount_client $MOUNT @@ -1409,7 +1409,7 @@ test_38() { # bug 14222 [ $V ] && log "verifying $DIR/$tdir/$f" diff -q $f $DIR/$tdir/$f || ERROR=y done - do_facet $SINGLEMDS "debugfs -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV" + do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV" do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new1" umount_client $MOUNT stop_mds diff --git a/lustre/tests/lfscktest.sh b/lustre/tests/lfscktest.sh index 61534b6..af7d794 100755 --- a/lustre/tests/lfscktest.sh +++ b/lustre/tests/lfscktest.sh @@ -133,7 +133,7 @@ if [ "$LFSCK_SETUP" != "no" ]; then for i in $OST_REMOVE; do echo "rm O/0/d$((i % 32))/$i" >> $DEBUGTMP done - debugfs -w -f $DEBUGTMP `echo $OSTDEVS | cut -d' ' -f 1` + $DEBUGFS -w -f $DEBUGTMP `echo $OSTDEVS | cut -d' ' -f 1` RET=$? rm $DEBUGTMP [ $RET -ne 0 ] && exit 50 @@ -175,19 +175,19 @@ fi # LFSCK_SETUP # a return status of 1 indicates e2fsck successfuly fixed problems found set +e -echo "e2fsck -d -v -fn --mdsdb $MDSDB $MDSDEV" +echo "$E2FSCK -d -v -fn --mdsdb $MDSDB $MDSDEV" df > /dev/null # update statfs data on disk -e2fsck -d -v -fn --mdsdb $MDSDB $MDSDEV +$E2FSCK -d -v -fn --mdsdb $MDSDB $MDSDEV RET=$? -[ $RET -gt $MAX_ERR ] && echo "e2fsck returned $RET" && exit 90 || true +[ $RET -gt $MAX_ERR ] && echo "$E2FSCK returned $RET" && exit 90 || true export OSTDB_LIST="" i=0 for OSTDEV in $OSTDEVS; do df > /dev/null # update statfs data on disk - e2fsck -d -v -fn --mdsdb $MDSDB --ostdb $OSTDB-$i $OSTDEV + $E2FSCK -d -v -fn --mdsdb $MDSDB --ostdb $OSTDB-$i $OSTDEV RET=$? - [ $RET -gt $MAX_ERR ] && echo "e2fsck returned $RET" && exit 100 + [ $RET -gt $MAX_ERR ] && echo "$E2FSCK returned $RET" && exit 100 OSTDB_LIST="$OSTDB_LIST $OSTDB-$i" i=$((i + 1)) done @@ -209,19 +209,19 @@ echo "LFSCK TEST 1 - finished with rc=$RET" sync; sleep 2; sync echo "LFSCK TEST 2" -echo "e2fsck -d -v -fn --mdsdb $MDSDB $MDSDEV" +echo "$E2FSCK -d -v -fn --mdsdb $MDSDB $MDSDEV" df > /dev/null # update statfs data on disk -e2fsck -d -v -fn --mdsdb $MDSDB $MDSDEV +$E2FSCK -d -v -fn --mdsdb $MDSDB $MDSDEV RET=$? -[ $RET -gt $MAX_ERR ] && echo "e2fsck returned $RET" && exit 123 || true +[ $RET -gt $MAX_ERR ] && echo "$E2FSCK returned $RET" && exit 123 || true i=0 export OSTDB_LIST="" for OSTDEV in $OSTDEVS; do df > /dev/null # update statfs data on disk - e2fsck -d -v -fn --mdsdb $MDSDB --ostdb $OSTDB-$i $OSTDEV + $E2FSCK -d -v -fn --mdsdb $MDSDB --ostdb $OSTDB-$i $OSTDEV RET=$? - [ $RET -gt $MAX_ERR ] && echo "e2fsck returned $RET" && exit 124 + [ $RET -gt $MAX_ERR ] && echo "$E2FSCK returned $RET" && exit 124 OSTDB_LIST="$OSTDB_LIST $OSTDB-$i" i=$((i + 1)) done diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index d195313..ebddc01 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -2716,7 +2716,7 @@ test_57a() { DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV) [ -z "$DEV" ] && error "can't access $MNTDEV" for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do - do_facet $SINGLEMDS dumpe2fs -h $DEV > $TMP/t57a.dump || error "can't access $DEV" + do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump || error "can't access $DEV" DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump` [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE" rm $TMP/t57a.dump diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index b65d23e..b270e91 100644 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -86,6 +86,13 @@ init_test_env() { export TESTSUITE=`basename $0 .sh` export TEST_FAILED=false + export MKE2FS=${MKE2FS:-mke2fs} + export DEBUGFS=${DEBUGFS:-debugfs} + export TUNE2FS=${TUNE2FS:-tune2fs} + export E2LABEL=${E2LABEL:-e2label} + export DUMPE2FS=${DUMPE2FS:-dumpe2fs} + export E2FSCK=${E2FSCK:-e2fsck} + #[ -d /r ] && export ROOT=${ROOT:-/r} export TMP=${TMP:-$ROOT/tmp} export TESTSUITELOG=${TMP}/${TESTSUITE}.log @@ -462,7 +469,7 @@ mount_facet() { lctl set_param debug_mb=${DEBUG_SIZE}; \ sync" - label=$(do_facet ${facet} "e2label ${!dev}") + label=$(do_facet ${facet} "$E2LABEL ${!dev}") [ -z "$label" ] && echo no label for ${!dev} && exit 1 eval export ${facet}_svc=${label} echo Started ${label} @@ -1393,7 +1400,7 @@ init_facet_vars () { eval export ${facet}_opt=\"$@\" local dev=${facet}_dev - local label=$(do_facet ${facet} "e2label ${!dev}") + local label=$(do_facet ${facet} "$E2LABEL ${!dev}") [ -z "$label" ] && echo no label for ${!dev} && exit 1 eval export ${facet}_svc=${label} diff --git a/lustre/utils/lr_reader.c b/lustre/utils/lr_reader.c index 996f4d9..5a2b11f 100644 --- a/lustre/utils/lr_reader.c +++ b/lustre/utils/lr_reader.c @@ -39,6 +39,10 @@ */ /* Safely read the last_rcvd file from a device */ +#if HAVE_CONFIG_H +# include "config.h" +#endif /* HAVE_CONFIG_H */ + #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif @@ -122,8 +126,8 @@ int main(int argc, char *const argv[]) memset(cmd, 0, sizeof(cmd)); sprintf(cmd, - "debugfs -c -R 'dump /%s %s/%s' %s", - LAST_RCVD, tmpdir, LAST_RCVD, dev); + "%s -c -R 'dump /%s %s/%s' %s", + DEBUGFS, LAST_RCVD, tmpdir, LAST_RCVD, dev); ret = run_command(cmd); if (ret) { @@ -193,8 +197,8 @@ int main(int argc, char *const argv[]) /* Construct debugfs command line. */ memset(cmd, 0, sizeof(cmd)); sprintf(cmd, - "debugfs -c -R 'rdump /%s %s' %s", - MDT_LOGS_DIR, tmpdir, dev); + "%s -c -R 'rdump /%s %s' %s", + DEBUGFS, MDT_LOGS_DIR, tmpdir, dev); run_command(cmd); diff --git a/lustre/utils/mkfs_lustre.c b/lustre/utils/mkfs_lustre.c index 8f54f8b..83d9a11 100644 --- a/lustre/utils/mkfs_lustre.c +++ b/lustre/utils/mkfs_lustre.c @@ -40,6 +40,10 @@ /* This source file is compiled into both mkfs.lustre and tunefs.lustre */ +#if HAVE_CONFIG_H +# include "config.h" +#endif /* HAVE_CONFIG_H */ + #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif @@ -376,22 +380,25 @@ static void disp_old_e2fsprogs_msg(const char *feature, int make_backfs) static int msg_displayed; if (msg_displayed) { - fprintf(stderr, "WARNING: e2fsprogs does not support %s " - "feature.\n\n", feature); + fprintf(stderr, "WARNING: %s does not support %s " + "feature.\n\n", E2FSPROGS, feature); return; } msg_displayed++; - fprintf(stderr, "WARNING: The e2fsprogs package currently installed on " - "your system does not support \"%s\" feature.\nPlease install " - "the latest version of e2fsprogs from http://downloads.lustre.org" - "/public/tools/e2fsprogs/\nto enable this feature.\n", feature); - + fprintf(stderr, "WARNING: The %s package currently installed on " + "your system does not support \"%s\" feature.\n", + E2FSPROGS, feature); +#if !(HAVE_LDISKFSPROGS) + fprintf(stderr, "Please install the latest version of e2fsprogs from\n" + "http://downloads.lustre.org/public/tools/e2fsprogs/\n" + "to enable this feature.\n"); +#endif if (make_backfs) - fprintf(stderr, "Feature will not be enabled until e2fsprogs " - "is updated and 'tune2fs -O %s %%{device}' " - "is run.\n\n", feature); + fprintf(stderr, "Feature will not be enabled until %s" + "is updated and '%s -O %s %%{device}' " + "is run.\n\n", E2FSPROGS, TUNE2FS, feature); } /* Check whether the file exists in the device */ @@ -404,8 +411,8 @@ static int file_in_dev(char *file_name, char *dev_name) /* Construct debugfs command line. */ snprintf(debugfs_cmd, sizeof(debugfs_cmd), - "debugfs -c -R 'stat %s' '%s' 2>&1 | egrep '(Inode|unsupported)'", - file_name, dev_name); + "%s -c -R 'stat %s' '%s' 2>&1 | egrep '(Inode|unsupported)'", + DEBUGFS, file_name, dev_name); fp = popen(debugfs_cmd, "r"); if (!fp) { @@ -467,8 +474,8 @@ static int is_e2fsprogs_feature_supp(const char *feature) int fd = -1; int ret = 0; - snprintf(cmd, sizeof(cmd), - "debugfs -c -R \"supported_features %s\" 2>&1", feature); + snprintf(cmd, sizeof(cmd), "%s -c -R \"supported_features %s\" 2>&1", + DEBUGFS, feature); /* Using popen() instead of run_command() since debugfs does not return * proper error code if command is not supported */ @@ -486,8 +493,8 @@ static int is_e2fsprogs_feature_supp(const char *feature) if ((fd = mkstemp(imgname)) < 0) return -1; - snprintf(cmd, sizeof(cmd), "mke2fs -F -O %s %s 100 >/dev/null 2>&1", - feature, imgname); + snprintf(cmd, sizeof(cmd), "%s -F -O %s %s 100 >/dev/null 2>&1", + MKE2FS, feature, imgname); /* run_command() displays the output of mke2fs when it fails for * some feature, so use system() directly */ ret = system(cmd); @@ -657,7 +664,7 @@ int make_lustre_backfs(struct mkfs_opts *mop) strscat(mop->mo_mkfsopts, " -F", sizeof(mop->mo_mkfsopts)); snprintf(mkfs_cmd, sizeof(mkfs_cmd), - "mkfs.ext2 -j -b %d -L %s ", L_BLOCK_SIZE, + "%s -j -b %d -L %s ", MKE2FS, L_BLOCK_SIZE, mop->mo_ldd.ldd_svname); } else if (mop->mo_ldd.ldd_mount_type == LDD_MT_REISERFS) { long journal_sz = 0; /* FIXME default journal size */ @@ -943,8 +950,8 @@ int read_local_files(struct mkfs_opts *mop) filesystem */ /* Construct debugfs command line. */ - snprintf(cmd, cmdsz, "debugfs -c -R 'dump /%s %s/mountdata' '%s'", - MOUNT_DATA_FILE, tmpdir, dev); + snprintf(cmd, cmdsz, "%s -c -R 'dump /%s %s/mountdata' '%s'", + DEBUGFS, MOUNT_DATA_FILE, tmpdir, dev); ret = run_command(cmd, cmdsz); if (ret) @@ -967,8 +974,8 @@ int read_local_files(struct mkfs_opts *mop) sprintf(filepnm, "%s/%s", tmpdir, LAST_RCVD); /* Construct debugfs command line. */ - snprintf(cmd, cmdsz, "debugfs -c -R 'dump /%s %s' %s", - LAST_RCVD, filepnm, dev); + snprintf(cmd, cmdsz, "%s -c -R 'dump /%s %s' %s", + DEBUGFS, LAST_RCVD, filepnm, dev); ret = run_command(cmd, cmdsz); if (ret) { @@ -987,7 +994,8 @@ int read_local_files(struct mkfs_opts *mop) snprintf(cmd, cmdsz, "ls -l %s/", tmpdir); run_command(cmd, cmdsz); verrprint("Contents of disk:\n"); - snprintf(cmd, cmdsz, "debugfs -c -R 'ls -l /' %s", dev); + snprintf(cmd, cmdsz, "%s -c -R 'ls -l /' %s", + DEBUGFS, dev); run_command(cmd, cmdsz); goto out_rmdir; @@ -1019,8 +1027,8 @@ int read_local_files(struct mkfs_opts *mop) } else { /* If neither is set, we're pre-1.4.6, make a guess. */ /* Construct debugfs command line. */ - snprintf(cmd, cmdsz, "debugfs -c -R 'rdump /%s %s' %s", - MDT_LOGS_DIR, tmpdir, dev); + snprintf(cmd, cmdsz, "%s -c -R 'rdump /%s %s' %s", + DEBUGFS, MDT_LOGS_DIR, tmpdir, dev); run_command(cmd, cmdsz); sprintf(filepnm, "%s/%s", tmpdir, MDT_LOGS_DIR); diff --git a/lustre/utils/mount_utils.c b/lustre/utils/mount_utils.c index bbe5d8b..02835cd 100644 --- a/lustre/utils/mount_utils.c +++ b/lustre/utils/mount_utils.c @@ -34,6 +34,10 @@ * Lustre is a trademark of Sun Microsystems, Inc. */ +#if HAVE_CONFIG_H +# include "config.h" +#endif /* HAVE_CONFIG_H */ + #include #include #include @@ -114,8 +118,8 @@ int get_mountdata(char *dev, struct lustre_disk_data *mo_ldd) return errno; } - snprintf(cmd, cmdsz, "/sbin/debugfs -c -R 'dump /%s %s/mountdata' %s", - MOUNT_DATA_FILE, tmpdir, dev); + snprintf(cmd, cmdsz, "%s -c -R 'dump /%s %s/mountdata' %s", + DEBUGFS, MOUNT_DATA_FILE, tmpdir, dev); ret = run_command(cmd, cmdsz); if (ret) { -- 1.8.3.1