From b38f26f7df29527d345050a58d6ad2144f3ac708 Mon Sep 17 00:00:00 2001 From: Nathan Rutman Date: Thu, 24 Jun 2010 10:08:59 -0700 Subject: [PATCH] b=22464 add writeconf as mount option i=alexg i=adilger --- lustre/include/lustre_disk.h | 3 ++- lustre/mgs/mgs_handler.c | 4 ++++ lustre/obdclass/obd_mount.c | 13 +++++++++---- lustre/tests/conf-sanity.sh | 35 ++++++++++++++++++++++++++++++++--- 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/lustre/include/lustre_disk.h b/lustre/include/lustre_disk.h index b14eb82..d95e846 100644 --- a/lustre/include/lustre_disk.h +++ b/lustre/include/lustre_disk.h @@ -63,7 +63,7 @@ #define LDD_F_SV_TYPE_MGS 0x0004 #define LDD_F_NEED_INDEX 0x0010 /* need an index assignment */ #define LDD_F_VIRGIN 0x0020 /* never registered */ -#define LDD_F_UPDATE 0x0040 /* update all related config logs */ +#define LDD_F_UPDATE 0x0040 /* update config for this server */ #define LDD_F_REWRITE_LDD 0x0080 /* rewrite the LDD */ #define LDD_F_WRITECONF 0x0100 /* regenerate all logs for this fs */ #define LDD_F_UPGRADE14 0x0200 /* COMPAT_14 */ @@ -172,6 +172,7 @@ struct lustre_mount_data { no other services */ #define LMD_FLG_NOMGS 0x0020 /* Only start target for servers, reusing existing MGS services */ +#define LMD_FLG_WRITECONF 0x0040 /* Rewrite config log */ #define lmd_is_client(x) ((x)->lmd_flags & LMD_FLG_CLIENT) diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index 9d6392b..4e85cd4 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -407,12 +407,16 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req) lustre_swab_mgs_target_info); LASSERT(mti); + if (mti->mti_flags & LDD_F_NEED_INDEX) + mti->mti_flags |= LDD_F_WRITECONF; + if (!(mti->mti_flags & (LDD_F_WRITECONF | LDD_F_UPGRADE14 | LDD_F_UPDATE))) { /* We're just here as a startup ping. */ CDEBUG(D_MGS, "Server %s is running on %s\n", mti->mti_svname, obd_export_nid2str(req->rq_export)); rc = mgs_check_target(obd, mti); + /* above will set appropriate mti flags */ if (rc <= 0) /* Nothing wrong, or fatal error */ diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index 1dc093d..7c86a97 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -949,6 +949,8 @@ static int server_sb2mti(struct super_block *sb, struct mgs_target_info *mti) mti->mti_lustre_ver = LUSTRE_VERSION_CODE; mti->mti_config_ver = 0; + if (lsi->lsi_lmd->lmd_flags & LMD_FLG_WRITECONF) + ldd->ldd_flags |= LDD_F_WRITECONF; mti->mti_flags = ldd->ldd_flags; mti->mti_stripe_index = ldd->ldd_svindex; memcpy(mti->mti_uuid, ldd->ldd_uuid, sizeof(mti->mti_uuid)); @@ -1352,7 +1354,7 @@ out_free: /* Wait here forever until the mount refcount is 0 before completing umount, * else we risk dereferencing a null pointer. - * LNET may take e.g. 165s before killing zombies. + * LNET may take e.g. 165s before killing zombies. */ static void server_wait_finished(struct vfsmount *mnt) { @@ -1370,16 +1372,16 @@ static void server_wait_finished(struct vfsmount *mnt) waited); /* Cannot use l_event_wait() for an interruptible sleep. */ waited += 3; - blocked = l_w_e_set_sigs(sigmask(SIGKILL)); + blocked = l_w_e_set_sigs(sigmask(SIGKILL)); rc = cfs_waitq_wait_event_interruptible_timeout( - waitq, + waitq, (cfs_atomic_read(&mnt->mnt_count) == 1), cfs_time_seconds(3)); cfs_block_sigs(blocked); if (rc < 0) { LCONSOLE_EMERG("Danger: interrupted umount %p with " "%d refs!\n", - mnt, atomic_read(&mnt->mnt_count)); + mnt, atomic_read(&mnt->mnt_count)); break; } } @@ -1902,6 +1904,9 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) } else if (strncmp(s1, "nomgs", 5) == 0) { lmd->lmd_flags |= LMD_FLG_NOMGS; clear++; + } else if (strncmp(s1, "writeconf", 9) == 0) { + lmd->lmd_flags |= LMD_FLG_WRITECONF; + clear++; /* ost exclusion list */ } else if (strncmp(s1, "exclude=", 8) == 0) { rc = lmd_make_exclusion(lmd, s1 + 7); diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index ef2ba73..373118c 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -90,7 +90,7 @@ start_mgs () { start_mds() { echo "start mds service on `facet_active_host mds`" - start mds $MDSDEV $MDS_MOUNT_OPTS || return 94 + start mds $MDSDEV $MDS_MOUNT_OPTS $@ || return 94 } stop_mgs() { @@ -107,7 +107,7 @@ stop_mds() { start_ost() { echo "start ost1 service on `facet_active_host ost1`" - start ost1 `ostdevname 1` $OST_MOUNT_OPTS || return 95 + start ost1 `ostdevname 1` $OST_MOUNT_OPTS $@ || return 95 } stop_ost() { @@ -118,7 +118,7 @@ stop_ost() { start_ost2() { echo "start ost2 service on `facet_active_host ost2`" - start ost2 `ostdevname 2` $OST_MOUNT_OPTS || return 92 + start ost2 `ostdevname 2` $OST_MOUNT_OPTS $@ || return 92 } stop_ost2() { @@ -2267,3 +2267,32 @@ fi equals_msg `basename $0`: test complete [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true +count_osts() { + do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l +} + +test_58() { + start_mds >> /dev/null + local C1=$(count_osts) + echo "original ost count: $C1 (expect > 0)" + stop_mds >> /dev/null + start_mds -o writeconf >> /dev/null || error "MDT start failed" + local C2=$(count_osts) + echo "after mdt writeconf count: $C2 (expect 0)" + [ $C1 -gt 0 ] && [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs" + echo "OST start without writeconf should fail:" + start_ost >> /dev/null && error "OST start without writeconf didn't fail" + echo "OST start with writeconf should succeed:" + start_ost -o writeconf >> /dev/null || error "OST1 start failed" + local C3=$(count_osts) + echo "after ost writeconf count: $C3 (expect 1)" + [ $C3 -eq 1 ] || error "new OST writeconf should add:" + start_ost2 -o writeconf >> /dev/null || error "OST2 start failed" + local C4=$(count_osts) + echo "after ost2 writeconf count: $C4 (expect 2)" + [ $C4 -eq 2 ] || error "OST2 writeconf should add log" + stop_ost2 >> /dev/null + cleanup_nocli >> /dev/null +} +run_test 58 "writeconf mount option" + -- 1.8.3.1