From 69943df8fe30386aac8a4112340c2a39483bfea2 Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 23 May 2006 18:58:35 +0000 Subject: [PATCH] Branch b1_5 b=9861 implement abort_recov mount option improve comments --- lustre/include/lustre_disk.h | 7 +++-- lustre/mgs/mgs_llog.c | 52 +++++++++++++++----------------- lustre/obdclass/obd_mount.c | 72 ++++++++++++-------------------------------- lustre/utils/mount_lustre.c | 1 + 4 files changed, 48 insertions(+), 84 deletions(-) diff --git a/lustre/include/lustre_disk.h b/lustre/include/lustre_disk.h index 0e2323e..0e9184e 100644 --- a/lustre/include/lustre_disk.h +++ b/lustre/include/lustre_disk.h @@ -144,9 +144,10 @@ struct lustre_mount_data { __u32 *lmd_exclude; /* array of OSTs to ignore */ }; -#define LMD_FLG_CLIENT 0x0002 /* Mounting a client only */ -#define LMD_FLG_RECOVER 0x0004 /* Allow recovery */ -#define LMD_FLG_NOSVC 0x0008 /* Only start MGS/MGC for servers, +#define LMD_FLG_SERVER 0x0001 /* Mounting a server */ +#define LMD_FLG_CLIENT 0x0002 /* Mounting a client */ +#define LMD_FLG_ABORT_RECOV 0x0008 /* Abort recovery */ +#define LMD_FLG_NOSVC 0x0010 /* Only start MGS/MGC for servers, no other services */ #define lmd_is_client(x) ((x)->lmd_flags & LMD_FLG_CLIENT) diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index 6026df3..8f41ad0 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -105,9 +105,12 @@ static inline void name_destroy(char *name) /* from the (client) config log, figure out: 1. which ost's/mdt's are configured (by index) 2. what the last config step is + 3. COMPAT_146 lov name + 4. COMPAT_146 mdt lov name + 5. COMPAT_146 mdc name */ -/* FIXME is it better to have a separate db file, instead of parsing the info - out of the client log? */ +/* It might be better to have a separate db file, instead of parsing the info + out of the client log. This is slow and potentially error-prone. */ static int mgs_fsdb_handler(struct llog_handle *llh, struct llog_rec_hdr *rec, void *data) { @@ -706,8 +709,6 @@ static int mgs_log_is_empty(struct obd_device *obd, char *name) struct llog_handle *llh; int rc = 0; - /* FIXME cache the empty state in the db */ - push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); rc = llog_create(llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT), &llh, NULL, name); @@ -745,7 +746,7 @@ static int mgs_write_log_direct(struct obd_device *obd, struct fs_db *fsdb, /* write the lcfg in all logs for the given fs */ int mgs_write_log_direct_all(struct obd_device *obd, struct fs_db *fsdb, - char *fsname, struct lustre_cfg *lcfg) + char *fsname, struct lustre_cfg *lcfg) { struct mgs_obd *mgs = &obd->u.mgs; struct list_head dentry_list; @@ -755,7 +756,9 @@ int mgs_write_log_direct_all(struct obd_device *obd, struct fs_db *fsdb, ENTRY; /* We need to set params for any future logs - as well. FIXME Append this file to every new log. */ + as well. FIXME Append this file to every new log. + Actually, we should store as params (text), not llogs. Or + in a database. */ name_create(&logname, fsname, "-params"); if (mgs_log_is_empty(obd, logname)) { struct llog_handle *llh = NULL; @@ -966,6 +969,9 @@ static int mgs_write_log_mdt(struct obd_device *obd, struct fs_db *fsdb, if (mti->mti_flags & LDD_F_UPGRADE14) { /* Old client log already has MDC entry, but needs mount opt for new client name (lustre-client) */ + /* FIXME Old MDT log already has an old mount opt + which we should remove (currently handled by + class_del_profiles()) */ rc = record_mount_opt(obd, llh, cliname, fsdb->fsdb_clilov, fsdb->fsdb_mdc); /* end COMPAT_146 */ @@ -1064,19 +1070,14 @@ static int mgs_write_log_ost(struct obd_device *obd, struct fs_db *fsdb, /* The ost startup log */ /* If the ost log already exists, that means that someone reformatted - the ost and it called target_add again. - FIXME check and warn here, maybe inc config ver #? Or abort, - and claim there's already a server with that name? Maybe need - another flag to say it's okay to rewrite. - Heck, what do we do about the client and mds logs? We better - abort. */ + the ost and it called target_add again. */ if (!mgs_log_is_empty(obd, mti->mti_svname)) { LCONSOLE_ERROR("The config log for %s already exists, yet the " "server claims it never registered. It may have" " been reformatted, or the index changed. Use " " tunefs.lustre --writeconf to regenerate " " all logs.\n", mti->mti_svname); - return -EALREADY; + RETURN(-EALREADY); } /* attach obdfilter ost1 ost1_UUID @@ -1103,8 +1104,8 @@ static int mgs_write_log_ost(struct obd_device *obd, struct fs_db *fsdb, /* If we're upgrading, the old mdt log already has our entry. Let's do a fake one for fun. */ flags = CM_SKIP | CM_UPGRADE146; - /* FIXME add to all mdt logs for CMD */ - // FIXME need real mdt name -- but MDT may not have registered yet! + /* FIXME add to all MDT logs for CMD */ + /* FIXME need real MDT name, but MDT may not have registered yet! */ name_create(&logname, mti->mti_fsname, "-MDT0000"); mgs_write_log_osc(obd, fsdb, mti, logname, fsdb->fsdb_mdtlov, flags); name_destroy(logname); @@ -1200,6 +1201,7 @@ static int mgs_write_log_params(struct obd_device *obd, struct fs_db *fsdb, len = strlen(ptr); CDEBUG(D_MGS, "next param '%.*s'\n", len, ptr); + /* Stored in MOUNT_DATA_FILE, modified via tunefs.lustre */ if (class_match_param(ptr, PARAM_MGSNODE, &endptr) == 0) GOTO(end_while, rc); @@ -1298,17 +1300,10 @@ int mgs_check_failnid(struct obd_device *obd, struct mgs_target_info *mti) RETURN(-ENOENT); CDEBUG(D_MGS, "Checking for new failnids for %s\n", mti->mti_svname); - // FIXME check logs - /* FIXME we need a real database lookup. Create on-disk db of known - size, lookup by index */ - /* Check each nid, or check only nid0 and add all if nid0 is missing? - What if someone adds a net to a node? Better check everything. */ - /* if nid 0 is missing, mgs_write_log_add_failnid. - if just one nid is missing, add uuid for nodeuuid[nid0]). - */ - /* Hey, we can just check mti->params to see if we're already in - the failover list */ + /* FIXME We can just check mti->params to see if we're already in + the failover list. Modify mti->params for rewriting back at + server_register_target(). */ down(&fsdb->fsdb_sem); rc = mgs_write_log_add_failnid(obd, fsdb, mti); @@ -1346,8 +1341,11 @@ int mgs_write_log_target(struct obd_device *obd, } else { if (rc == EALREADY) { /* Update a target entry in the logs */ - // FIXME mark old log sections as invalid, add new. CERROR("updates not yet implemented\n"); + /* FIXME mark old log sections as invalid, + inc config ver #, add new log sections. + Make sure to update client and mds logs too + if needed */ RETURN(-ENXIO); } } @@ -1429,8 +1427,6 @@ int mgs_upgrade_sv_14(struct obd_device *obd, struct mgs_target_info *mti) RETURN(-ENOENT); } - /* FIXME Old MDT log already has an old mount opt - which we should drop */ rc = mgs_write_log_target(obd, mti); RETURN(rc); } diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index 46fa03d..c7724bc 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -201,37 +201,6 @@ static int server_deregister_mount(char *name) RETURN(0); } -/* Deregister anyone referencing the mnt. Everyone should have - put_mount in *_cleanup, but this is a catch-all in case of err... */ -/* FIXME this should be removed from lustre_free_lsi, which may be called - from server_put_mount _before_ it gets to server_deregister_mount. - Leave it here for now for the error message it shows... */ -static void server_deregister_mount_all(struct vfsmount *mnt) -{ - struct list_head *tmp, *n; - struct lustre_mount_info *lmi; - ENTRY; - - if (!mnt) { - EXIT; - return; - } - - //down(&lustre_mount_info_lock); - list_for_each_safe(tmp, n, &server_mount_info_list) { - lmi = list_entry(tmp, struct lustre_mount_info, lmi_list_chain); - if (lmi->lmi_mnt == mnt) { - CERROR("Mount %p still referenced by %s\n", mnt, - lmi->lmi_name); - //OBD_FREE(lmi->lmi_name, strlen(lmi->lmi_name) + 1); - //list_del(&lmi->lmi_list_chain); - //OBD_FREE(lmi, sizeof(*lmi)); - } - } - //up(&lustre_mount_info_lock); - EXIT; -} - /* obd's look up a registered mount using their name. This is just for initial obd setup to find the mount struct. It should not be called every time you want to mntget. */ @@ -753,9 +722,6 @@ static int lustre_start_mgc(struct super_block *sb) /* nonfatal */ CERROR("can't set %s %d\n", KEY_INIT_RECOV_BACKUP, rc); - /* FIXME add ACL support? */ - //ocd.ocd_connect_flags = OBD_CONNECT_ACL; - /* We connect to the MGS at setup, and don't disconnect until cleanup */ rc = obd_connect(&mgc_conn, obd, &(obd->obd_uuid), &ocd); if (rc) { @@ -1095,11 +1061,17 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt) GOTO(out, rc); } - if (!class_name2obd(lsi->lsi_ldd->ldd_svname)) { + obd = class_name2obd(lsi->lsi_ldd->ldd_svname); + if (!obd) { CERROR("no server named %s was started\n", lsi->lsi_ldd->ldd_svname); - rc = -ENXIO; + GOTO(out, rc = -ENXIO); } + + if ((lsi->lsi_lmd->lmd_flags & LMD_FLG_ABORT_RECOV) && + (OBP(obd, iocontrol))) + obd_iocontrol(OBD_IOC_ABORT_RECOVERY, obd->obd_self_export, + 0, NULL, NULL); out: /* Release the mgc fs for others to use */ @@ -1170,8 +1142,6 @@ static int lustre_free_lsi(struct super_block *sb) LASSERT(lsi->lsi_llsbi == NULL); - server_deregister_mount_all(lsi->lsi_srv_mnt); - OBD_FREE(lsi, sizeof(*lsi)); s2lsi_nocast(sb) = NULL; @@ -1217,17 +1187,17 @@ static struct vfsmount *server_kernel_mount(struct super_block *sb) Note ext3/ldiskfs can't be mounted ro. */ s_flags = sb->s_flags; - /* Pre-mount ext3 to read the MOUNT_DATA_FILE */ - CDEBUG(D_MOUNT, "Pre-mount ext3 %s\n", lmd->lmd_dev); - mnt = do_kern_mount("ext3", s_flags, lmd->lmd_dev, 0); + /* Pre-mount ldiskfs to read the MOUNT_DATA_FILE */ + CDEBUG(D_MOUNT, "Pre-mount ldiskfs %s\n", lmd->lmd_dev); + mnt = do_kern_mount("ldiskfs", s_flags, lmd->lmd_dev, 0); if (IS_ERR(mnt)) { rc = PTR_ERR(mnt); - CERROR("premount ext3 failed (%d), trying ldiskfs\n", rc); - /* If ext3 fails (bec. of mballoc, extents), try ldiskfs */ - mnt = do_kern_mount("ldiskfs", s_flags, lmd->lmd_dev, 0); + CERROR("premount ldiskfs failed (%d), trying ext3\n", rc); + /* If ldisk fails, try ext3 */ + mnt = do_kern_mount("ext3", s_flags, lmd->lmd_dev, 0); if (IS_ERR(mnt)) { rc = PTR_ERR(mnt); - CERROR("premount ldiskfs failed: rc = %d\n", rc); + CERROR("premount ext3 failed: rc = %d\n", rc); GOTO(out_free, rc); } } @@ -1712,8 +1682,7 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) } lmd->lmd_magic = LMD_MAGIC; - /* Default flags */ - lmd->lmd_flags |= LMD_FLG_RECOVER; + /* Set default flags here */ s1 = options; while (*s1) { @@ -1724,14 +1693,11 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) /* Client options are parsed in ll_options: eg. flock, user_xattr, acl */ - if (strncmp(s1, "recov", 5) == 0) - /* FIXME do something with the RECOVER flag - see lconf */ - lmd->lmd_flags |= LMD_FLG_RECOVER; - else if (strncmp(s1, "norecov", 7) == 0) - lmd->lmd_flags &= ~LMD_FLG_RECOVER; + /* Parse non-ldiskfs options here */ + if (strncmp(s1, "abort_recov", 11) == 0) + lmd->lmd_flags |= LMD_FLG_ABORT_RECOV; else if (strncmp(s1, "nosvc", 5) == 0) lmd->lmd_flags |= LMD_FLG_NOSVC; - /* ost exclusion list */ else if (strncmp(s1, "exclude=", 8) == 0) { rc = lmd_make_exclusion(lmd, s1 + 7); diff --git a/lustre/utils/mount_lustre.c b/lustre/utils/mount_lustre.c index f1edb63..212cbdb 100644 --- a/lustre/utils/mount_lustre.c +++ b/lustre/utils/mount_lustre.c @@ -209,6 +209,7 @@ static const struct opt_map opt_map[] = { { "noacl", 1, 1, 0 }, /* Disable ACL support */ { "nosvc", 0, 0, 0 }, /* Only start MGS/MGC, nothing else */ { "exclude", 0, 0, 0 }, /* OST exclusion list */ + { "abort_recov", 0, 0, 0 }, /* Abort recovery */ { NULL, 0, 0, 0 } }; /****************************************************************************/ -- 1.8.3.1