From 4d42827c3ec2584e7ca560a4b4906b24f60f6e64 Mon Sep 17 00:00:00 2001 From: nathan Date: Fri, 24 Mar 2006 00:04:39 +0000 Subject: [PATCH] Branch b1_4_mountconf b=9858 stupid strsep caused memory leak, more changes for conf-sanity --- lustre/llite/llite_internal.h | 1 - lustre/llite/llite_lib.c | 62 ++++++++++++++++++++---------------------- lustre/obdclass/obd_mount.c | 2 +- lustre/tests/conf-sanity.sh | 10 +++---- lustre/tests/test-framework.sh | 14 ++++------ 5 files changed, 41 insertions(+), 48 deletions(-) diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 5239302..78a0814 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -402,7 +402,6 @@ int ll_dcompare(struct dentry *parent, struct qstr *d_name, struct qstr *name); extern struct super_operations lustre_super_operations; char *ll_read_opt(const char *opt, char *data); -int ll_set_opt(const char *opt, char *data, int fl); void ll_options(char *options, int *flags); void ll_lli_init(struct ll_inode_info *lli); int ll_fill_super(struct super_block *sb); diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 302bd88..80b3bcd 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -501,25 +501,19 @@ char *ll_read_opt(const char *opt, char *data) RETURN(retval); } -int ll_set_opt(const char *opt, char *data, int fl) +static inline int ll_set_opt(const char *opt, char *data, int fl) { - ENTRY; - - CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data); if (strncmp(opt, data, strlen(opt)) != 0) - RETURN(0); + return(0); else - RETURN(fl); + return(fl); } /* non-client-specific mount options are parsed in lmd_parse */ void ll_options(char *options, int *flags) { int tmp; - char *this_char; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) - char *opt_ptr = options; -#endif + char *s1 = options, *s2; ENTRY; if (!options) { @@ -528,51 +522,52 @@ void ll_options(char *options, int *flags) } CDEBUG(D_CONFIG, "Parsing opts %s\n", options); -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) - for (this_char = strtok (options, ","); - this_char != NULL; - this_char = strtok (NULL, ",")) -#else - while ((this_char = strsep (&opt_ptr, ",")) != NULL) -#endif - { - CDEBUG(D_SUPER, "this_char %s\n", this_char); - tmp = ll_set_opt("nolock", this_char, LL_SBI_NOLCK); + + while (*s1) { + CDEBUG(D_SUPER, "next opt=%s\n", s1); + tmp = ll_set_opt("nolock", s1, LL_SBI_NOLCK); if (tmp) { *flags |= tmp; - continue; + goto next; } - tmp = ll_set_opt("flock", this_char, LL_SBI_FLOCK); + tmp = ll_set_opt("flock", s1, LL_SBI_FLOCK); if (tmp) { *flags |= tmp; - continue; + goto next; } - tmp = ll_set_opt("noflock", this_char, LL_SBI_FLOCK); + tmp = ll_set_opt("noflock", s1, LL_SBI_FLOCK); if (tmp) { *flags &= ~tmp; - continue; + goto next; } - tmp = ll_set_opt("user_xattr", this_char, LL_SBI_USER_XATTR); + tmp = ll_set_opt("user_xattr", s1, LL_SBI_USER_XATTR); if (tmp) { *flags |= tmp; - continue; + goto next; } - tmp = ll_set_opt("nouser_xattr", this_char, LL_SBI_USER_XATTR); + tmp = ll_set_opt("nouser_xattr", s1, LL_SBI_USER_XATTR); if (tmp) { *flags &= ~tmp; - continue; + goto next; } - tmp = ll_set_opt("acl", this_char, LL_SBI_ACL); + tmp = ll_set_opt("acl", s1, LL_SBI_ACL); if (tmp) { /* Ignore deprecated mount option. The client will * always try to mount with ACL support, whether this * is used depends on whether server supports it. */ - continue; + goto next; } - tmp = ll_set_opt("noacl", this_char, LL_SBI_ACL); + tmp = ll_set_opt("noacl", s1, LL_SBI_ACL); if (tmp) { - continue; + goto next; } + +next: + /* Find next opt */ + s2 = strchr(s1, ','); + if (s2 == NULL) + break; + s1 = s2 + 1; } EXIT; } @@ -713,6 +708,7 @@ void ll_put_super(struct super_block *sb) lustre_common_put_super(sb); + CDEBUG(D_WARNING, "client umount done\n"); EXIT; } /* client_put_super */ diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index e02673cd..cb76cab 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -1335,7 +1335,7 @@ static void server_put_super(struct super_block *sb) is right. */ server_stop_servers(lddflags, lsiflags); - CDEBUG(D_MOUNT|D_WARNING, "umount done\n"); + CDEBUG(D_MOUNT|D_WARNING, "server umount done\n"); EXIT; } diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 1eb10cb..cbf46d5 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -92,9 +92,10 @@ setup() { cleanup() { umount_client $MOUNT || return 200 + sleep 2 stop_mds || return 201 stop_ost || return 202 - unload_modules && return 203 + unload_modules || return 203 } check_mount() { @@ -162,12 +163,11 @@ run_test 2 "start up mds twice" test_3() { setup - mount_client $MOUNT + #mount.lustre returns an error if already in mtab + mount_client $MOUNT && return $? check_mount || return 44 - - umount_client $MOUNT - cleanup || return $? + cleanup || return $? } run_test 3 "mount client twice" diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index a639f76..3431ef1 100644 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -88,7 +88,6 @@ unload_modules() { echo "Memory leaks detected" return 254 fi - return 0 } # Facet functions @@ -98,8 +97,8 @@ start() { shift device=$1 shift - echo "Starting ${device} as /mnt/${facet} (opts:$@)" - mkdir -p /mnt/${facet} + echo "Starting ${facet}: $@ ${device} /mnt/${facet}" + do_facet ${facet} mkdir -p /mnt/${facet} do_facet ${facet} mount -t lustre $@ ${device} /mnt/${facet} #do_facet $facet $LCONF --select ${facet}_svc=${active}_facet \ # --node ${active}_facet --ptldebug $PTLDEBUG --subsystem $SUBSYSTEM \ @@ -140,16 +139,15 @@ zconf_mount() { echo No mount point given: zconf_mount $* exit 1 fi - - do_node $client mkdir $mnt 2> /dev/null || : - # Only supply -o to mount if we have options if [ -n "$MOUNTOPT" ]; then OPTIONS="-o $MOUNTOPT" fi + echo "Starting client: $OPTIONS `facet_nid mgs`:/$FSNAME $mnt" + do_node $client mkdir -p $mnt do_node $client mount -t lustre $OPTIONS \ - `facet_nid mgs`:/lustre $mnt || return 1 + `facet_nid mgs`:/$FSNAME $mnt || return 1 do_node $client "sysctl -w lnet.debug=$PTLDEBUG; sysctl -w lnet.subsystem_debug=${SUBSYSTEM# }" @@ -563,7 +561,7 @@ pgcache_empty() { ################################## # Test interface error() { - sysctl -w lustre.fail_loc=0 || true + sysctl -w lustre.fail_loc=0 > /dev/null 2>&1 || true echo "${TESTSUITE}: **** FAIL:" $@ log "FAIL: $@" exit 1 -- 1.8.3.1