*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
*
* GPL HEADER END
*/
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 2014, Intel Corporation.
+ * Copyright (c) 2011, 2016, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
goto next;
}
+ /* filter out ".bak" files */
+ /* sizeof(".bak") - 1 == 3 */
+ if (key_sz >= 3 &&
+ !memcmp(".bak", key + key_sz - 3, 3)) {
+ CDEBUG(D_MGS, "Skipping backup file %.*s\n",
+ key_sz, key);
+ goto next;
+ }
+
de = mgs_direntry_alloc(key_sz + 1);
if (de == NULL) {
rc = -ENOMEM;
next:
rc = iops->next(env, it);
} while (rc == 0);
- rc = 0;
+ if (rc > 0)
+ rc = 0;
iops->put(env, it);
struct mgs_device *mgs,
struct fs_db *fsdb)
{
- char *logname;
- struct llog_handle *loghandle;
- struct llog_ctxt *ctxt;
- struct mgs_fsdb_handler_data d = { fsdb, 0 };
+ char *logname;
+ struct llog_handle *loghandle;
+ struct llog_ctxt *ctxt;
+ struct mgs_fsdb_handler_data d = {
+ .fsdb = fsdb,
+ };
int rc;
ENTRY;
set_bit(mti->mti_stripe_index, imap);
clear_bit(FSDB_LOG_EMPTY, &fsdb->fsdb_flags);
mutex_unlock(&fsdb->fsdb_mutex);
- server_make_name(mti->mti_flags & ~(LDD_F_VIRGIN | LDD_F_WRITECONF),
- mti->mti_stripe_index, mti->mti_fsname, mti->mti_svname);
+ if (server_make_name(mti->mti_flags & ~(LDD_F_VIRGIN | LDD_F_WRITECONF),
+ mti->mti_stripe_index, mti->mti_fsname,
+ mti->mti_svname)) {
+ CERROR("unknown server type %#x\n", mti->mti_flags);
+ return -EINVAL;
+ }
CDEBUG(D_MGS, "Set index for %s to %d\n", mti->mti_svname,
mti->mti_stripe_index);
int mml_modified;
};
+static int mgs_check_record_match(const struct lu_env *env,
+ struct llog_handle *llh,
+ struct llog_rec_hdr *rec, void *data)
+{
+ struct cfg_marker *mc_marker = data;
+ struct cfg_marker *marker;
+ struct lustre_cfg *lcfg = REC_DATA(rec);
+ int cfg_len = REC_DATA_LEN(rec);
+ int rc;
+ ENTRY;
+
+
+ if (rec->lrh_type != OBD_CFG_REC) {
+ CDEBUG(D_ERROR, "Unhandled lrh_type: %#x\n", rec->lrh_type);
+ RETURN(-EINVAL);
+ }
+
+ rc = lustre_cfg_sanity_check(lcfg, cfg_len);
+ if (rc) {
+ CDEBUG(D_ERROR, "Insane cfg\n");
+ RETURN(rc);
+ }
+
+ /* We only care about markers */
+ if (lcfg->lcfg_command != LCFG_MARKER)
+ RETURN(0);
+
+ marker = lustre_cfg_buf(lcfg, 1);
+
+ if (marker->cm_flags & CM_SKIP)
+ RETURN(0);
+
+ if ((strcmp(mc_marker->cm_comment, marker->cm_comment) == 0) &&
+ (strcmp(mc_marker->cm_tgtname, marker->cm_tgtname) == 0)) {
+ /* Found a non-skipped marker match */
+ CDEBUG(D_MGS, "Matched rec %u marker %d flag %x %s %s\n",
+ rec->lrh_index, marker->cm_step,
+ marker->cm_flags, marker->cm_tgtname,
+ marker->cm_comment);
+ rc = LLOG_PROC_BREAK;
+ }
+
+ RETURN(rc);
+}
+
+/**
+ * Check an existing config log record with matching comment and device
+ * Return code:
+ * 0 - checked successfully,
+ * LLOG_PROC_BREAK - record matches
+ * negative - error
+ */
+static int mgs_check_marker(const struct lu_env *env, struct mgs_device *mgs,
+ struct fs_db *fsdb, struct mgs_target_info *mti,
+ char *logname, char *devname, char *comment)
+{
+ struct llog_handle *loghandle;
+ struct llog_ctxt *ctxt;
+ struct cfg_marker *mc_marker;
+ int rc;
+
+ ENTRY;
+
+ LASSERT(mutex_is_locked(&fsdb->fsdb_mutex));
+ CDEBUG(D_MGS, "mgs check %s/%s/%s\n", logname, devname, comment);
+
+ ctxt = llog_get_context(mgs->mgs_obd, LLOG_CONFIG_ORIG_CTXT);
+ LASSERT(ctxt != NULL);
+ rc = llog_open(env, ctxt, &loghandle, NULL, logname, LLOG_OPEN_EXISTS);
+ if (rc < 0) {
+ if (rc == -ENOENT)
+ rc = 0;
+ GOTO(out_pop, rc);
+ }
+
+ rc = llog_init_handle(env, loghandle, LLOG_F_IS_PLAIN, NULL);
+ if (rc)
+ GOTO(out_close, rc);
+
+ if (llog_get_size(loghandle) <= 1)
+ GOTO(out_close, rc = 0);
+
+ OBD_ALLOC_PTR(mc_marker);
+ if (!mc_marker)
+ GOTO(out_close, rc = -ENOMEM);
+ if (strlcpy(mc_marker->cm_comment, comment,
+ sizeof(mc_marker->cm_comment)) >=
+ sizeof(mc_marker->cm_comment))
+ GOTO(out_free, rc = -E2BIG);
+ if (strlcpy(mc_marker->cm_tgtname, devname,
+ sizeof(mc_marker->cm_tgtname)) >=
+ sizeof(mc_marker->cm_tgtname))
+ GOTO(out_free, rc = -E2BIG);
+
+ rc = llog_process(env, loghandle, mgs_check_record_match,
+ (void *)mc_marker, NULL);
+
+out_free:
+ OBD_FREE_PTR(mc_marker);
+
+out_close:
+ llog_close(env, loghandle);
+out_pop:
+ if (rc && rc != LLOG_PROC_BREAK)
+ CDEBUG(D_ERROR, "%s: mgs check %s/%s failed: rc = %d\n",
+ mgs->mgs_obd->obd_name, mti->mti_svname, comment, rc);
+ llog_ctxt_put(ctxt);
+ RETURN(rc);
+}
+
static int mgs_modify_handler(const struct lu_env *env,
struct llog_handle *llh,
struct llog_rec_hdr *rec, void *data)
#14 L mount_option 0: 1:client 2:lov1 3:MDC_uml1_mdsA_MNT_client
*/
- /* copy client info about lov/lmv */
- mgi->mgi_comp.comp_mti = mti;
- mgi->mgi_comp.comp_fsdb = fsdb;
+ /* copy client info about lov/lmv */
+ mgi->mgi_comp.comp_mti = mti;
+ mgi->mgi_comp.comp_fsdb = fsdb;
- rc = mgs_steal_llog_for_mdt_from_client(env, mgs, cliname,
- &mgi->mgi_comp);
- if (rc)
- GOTO(out_free, rc);
- rc = mgs_write_log_mdc_to_lmv(env, mgs, fsdb, mti, cliname,
- fsdb->fsdb_clilmv);
- if (rc)
- GOTO(out_free, rc);
+ rc = mgs_steal_llog_for_mdt_from_client(env, mgs, cliname,
+ &mgi->mgi_comp);
+ if (rc)
+ GOTO(out_free, rc);
+ rc = mgs_write_log_mdc_to_lmv(env, mgs, fsdb, mti, cliname,
+ fsdb->fsdb_clilmv);
+ if (rc)
+ GOTO(out_free, rc);
- /* add mountopts */
- rc = record_start_log(env, mgs, &llh, cliname);
- if (rc)
- GOTO(out_free, rc);
+ /* add mountopts */
+ rc = record_start_log(env, mgs, &llh, cliname);
+ if (rc)
+ GOTO(out_free, rc);
- rc = record_marker(env, llh, fsdb, CM_START, cliname,
- "mount opts");
- if (rc)
- GOTO(out_end, rc);
- rc = record_mount_opt(env, llh, cliname, fsdb->fsdb_clilov,
- fsdb->fsdb_clilmv);
- if (rc)
- GOTO(out_end, rc);
- rc = record_marker(env, llh, fsdb, CM_END, cliname,
- "mount opts");
+ rc = record_marker(env, llh, fsdb, CM_START, cliname,
+ "mount opts");
+ if (rc)
+ GOTO(out_end, rc);
+ rc = record_mount_opt(env, llh, cliname, fsdb->fsdb_clilov,
+ fsdb->fsdb_clilmv);
+ if (rc)
+ GOTO(out_end, rc);
+ rc = record_marker(env, llh, fsdb, CM_END, cliname,
+ "mount opts");
if (rc)
GOTO(out_end, rc);
if (rc)
GOTO(out_end, rc);
- rc = mgs_write_log_osp_to_mdt(env, mgs, fsdb, mti,
- i, logname);
+ /* NB: If the log for the MDT is empty, it means
+ * the MDT is only added to the index
+ * map, and not being process yet, i.e. this
+ * is an unregistered MDT, see mgs_write_log_target().
+ * so we should skip it. Otherwise
+ *
+ * 1. MGS get register request for MDT1 and MDT2.
+ *
+ * 2. Then both MDT1 and MDT2 are added into
+ * fsdb_mdt_index_map. (see mgs_set_index()).
+ *
+ * 3. Then MDT1 get the lock of fsdb_mutex, then
+ * generate the config log, here, it will regard MDT2
+ * as an existent MDT, and generate "add osp" for
+ * lustre-MDT0001-osp-MDT0002. Note: at the moment
+ * MDT0002 config log is still empty, so it will
+ * add "add osp" even before "lov setup", which
+ * will definitly cause trouble.
+ *
+ * 4. MDT1 registeration finished, fsdb_mutex is
+ * released, then MDT2 get in, then in above
+ * mgs_steal_llog_for_mdt_from_client(), it will
+ * add another osp log for lustre-MDT0001-osp-MDT0002,
+ * which will cause another trouble.*/
+ if (!mgs_log_is_empty(env, mgs, logname))
+ rc = mgs_write_log_osp_to_mdt(env, mgs, fsdb,
+ mti, i, logname);
+
name_destroy(&logname);
if (rc)
GOTO(out_end, rc);
GOTO(out_free, rc);
}
rc = mgs_write_log_osc_to_lov(env, mgs, fsdb, mti, logname, "",
- fsdb->fsdb_clilov, LUSTRE_SP_CLI, 0);
+ fsdb->fsdb_clilov, LUSTRE_SP_CLI, flags);
out_free:
name_destroy(&logname);
RETURN(rc);
struct mgs_thread_info *mgi = mgs_env_info(env);
char *logname;
char *tmp;
- int rc = 0, rc2 = 0;
+ int rc = 0;
ENTRY;
/* For various parameter settings, we have to figure out which logs
}
LCONSOLE_WARN("Ignoring unrecognized param '%s'\n", ptr);
- rc2 = -ENOSYS;
end:
if (rc)
CERROR("err %d on param '%s'\n", rc, ptr);
- RETURN(rc ?: rc2);
-}
-
-/* Not implementing automatic failover nid addition at this time. */
-int mgs_check_failnid(const struct lu_env *env, struct mgs_device *mgs,
- struct mgs_target_info *mti)
-{
-#if 0
- struct fs_db *fsdb;
- int rc;
- ENTRY;
-
- rc = mgs_find_or_make_fsdb(obd, fsname, &fsdb);
- if (rc)
- RETURN(rc);
-
- if (mgs_log_is_empty(obd, mti->mti_svname))
- /* should never happen */
- RETURN(-ENOENT);
-
- CDEBUG(D_MGS, "Checking for new failnids for %s\n", mti->mti_svname);
-
- /* 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(). */
-
- mutex_lock(&fsdb->fsdb_mutex);
- rc = mgs_write_log_add_failnid(obd, fsdb, mti);
- mutex_unlock(&fsdb->fsdb_mutex);
- char *buf, *params;
- int rc = -EINVAL;
-
- RETURN(rc);
-#endif
- return 0;
+ RETURN(rc);
}
int mgs_write_log_target(const struct lu_env *env, struct mgs_device *mgs,
rc = 0;
}
+ OBD_FAIL_TIMEOUT(OBD_FAIL_MGS_WRITE_TARGET_DELAY, cfs_fail_val > 0 ?
+ cfs_fail_val : 10);
+
mutex_lock(&fsdb->fsdb_mutex);
if (mti->mti_flags &
bool_switch = simple_strtoul(param, NULL, 10);
rc = nodemap_set_allow_root(nodemap_name, bool_switch);
break;
+ case LCFG_NODEMAP_DENY_UNKNOWN:
+ bool_switch = simple_strtoul(param, NULL, 10);
+ rc = nodemap_set_deny_unknown(nodemap_name, bool_switch);
+ break;
case LCFG_NODEMAP_TRUSTED:
bool_switch = simple_strtoul(param, NULL, 10);
rc = nodemap_set_trust_client_ids(nodemap_name, bool_switch);
rc = nodemap_del_idmap(nodemap_name, NODEMAP_GID,
idmap);
break;
+ case LCFG_NODEMAP_SET_FILESET:
+ rc = nodemap_set_fileset(nodemap_name, param);
+ break;
default:
rc = -EINVAL;
}
char *label = NULL, *canceled_label = NULL;
int label_sz;
struct mgs_target_info *mti = NULL;
+ bool checked = false;
int rc, i;
ENTRY;
break;
}
- if (canceled_label != NULL) {
- OBD_ALLOC_PTR(mti);
- if (mti == NULL)
- GOTO(out_cancel, rc = -ENOMEM);
- }
+ OBD_ALLOC_PTR(mti);
+ if (mti == NULL)
+ GOTO(out_cancel, rc = -ENOMEM);
+ strncpy(mti->mti_svname, "lov pool", sizeof(mti->mti_svname));
mutex_lock(&fsdb->fsdb_mutex);
/* write pool def to all MDT logs */
mutex_unlock(&fsdb->fsdb_mutex);
GOTO(out_mti, rc);
}
- if (canceled_label != NULL) {
- strcpy(mti->mti_svname, "lov pool");
+
+ if (!checked && (canceled_label == NULL)) {
+ rc = mgs_check_marker(env, mgs, fsdb, mti,
+ logname, lovname, label);
+ if (rc) {
+ name_destroy(&logname);
+ name_destroy(&lovname);
+ mutex_unlock(&fsdb->fsdb_mutex);
+ GOTO(out_mti,
+ rc = (rc == LLOG_PROC_BREAK ?
+ -EEXIST : rc));
+ }
+ checked = true;
+ }
+ if (canceled_label != NULL)
rc = mgs_modify(env, mgs, fsdb, mti, logname,
lovname, canceled_label,
CM_SKIP);
- }
if (rc >= 0)
rc = mgs_write_log_pool(env, mgs, logname,
mutex_unlock(&fsdb->fsdb_mutex);
GOTO(out_mti, rc);
}
+
+ if (!checked && (canceled_label == NULL)) {
+ rc = mgs_check_marker(env, mgs, fsdb, mti, logname,
+ fsdb->fsdb_clilov, label);
+ if (rc) {
+ name_destroy(&logname);
+ mutex_unlock(&fsdb->fsdb_mutex);
+ GOTO(out_mti, rc = (rc == LLOG_PROC_BREAK ?
+ -EEXIST : rc));
+ }
+ }
if (canceled_label != NULL) {
rc = mgs_modify(env, mgs, fsdb, mti, logname,
fsdb->fsdb_clilov, canceled_label, CM_SKIP);