* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 2013, Intel Corporation.
+ * Copyright (c) 2011, 2014, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
struct fs_db *mgs_find_fsdb(struct mgs_device *mgs, char *fsname)
{
struct fs_db *fsdb;
- cfs_list_t *tmp;
+ struct list_head *tmp;
- cfs_list_for_each(tmp, &mgs->mgs_fs_db_list) {
- fsdb = cfs_list_entry(tmp, struct fs_db, fsdb_list);
+ list_for_each(tmp, &mgs->mgs_fs_db_list) {
+ fsdb = list_entry(tmp, struct fs_db, fsdb_list);
if (strcmp(fsdb->fsdb_name, fsname) == 0)
return fsdb;
}
lproc_mgs_add_live(mgs, fsdb);
}
- cfs_list_add(&fsdb->fsdb_list, &mgs->mgs_fs_db_list);
+ list_add(&fsdb->fsdb_list, &mgs->mgs_fs_db_list);
RETURN(fsdb);
err:
static void mgs_free_fsdb(struct mgs_device *mgs, struct fs_db *fsdb)
{
- /* wait for anyone with the sem */
+ /* wait for anyone with the sem */
mutex_lock(&fsdb->fsdb_mutex);
lproc_mgs_del_live(mgs, fsdb);
- cfs_list_del(&fsdb->fsdb_list);
+ list_del(&fsdb->fsdb_list);
/* deinitialize fsr */
mgs_ir_fini_fs(mgs, fsdb);
int mgs_init_fsdb_list(struct mgs_device *mgs)
{
- CFS_INIT_LIST_HEAD(&mgs->mgs_fs_db_list);
+ INIT_LIST_HEAD(&mgs->mgs_fs_db_list);
return 0;
}
int mgs_cleanup_fsdb_list(struct mgs_device *mgs)
{
- struct fs_db *fsdb;
- cfs_list_t *tmp, *tmp2;
+ struct fs_db *fsdb;
+ struct list_head *tmp, *tmp2;
+
mutex_lock(&mgs->mgs_mutex);
- cfs_list_for_each_safe(tmp, tmp2, &mgs->mgs_fs_db_list) {
- fsdb = cfs_list_entry(tmp, struct fs_db, fsdb_list);
+ list_for_each_safe(tmp, tmp2, &mgs->mgs_fs_db_list) {
+ fsdb = list_entry(tmp, struct fs_db, fsdb_list);
mgs_free_fsdb(mgs, fsdb);
- }
+ }
mutex_unlock(&mgs->mgs_mutex);
- return 0;
+ return 0;
}
int mgs_find_or_make_fsdb(const struct lu_env *env,
fsdb->fsdb_mdt_count ++;
}
- if (mti->mti_stripe_index >= INDEX_MAP_SIZE * 8) {
- LCONSOLE_ERROR_MSG(0x13f, "Server %s requested index %d, "
- "but the max index is %d.\n",
- mti->mti_svname, mti->mti_stripe_index,
- INDEX_MAP_SIZE * 8);
+ /* the last index(0xffff) is reserved for default value. */
+ if (mti->mti_stripe_index >= INDEX_MAP_SIZE * 8 - 1) {
+ LCONSOLE_ERROR_MSG(0x13f, "Server %s requested index %u, "
+ "but index must be less than %u.\n",
+ mti->mti_svname, mti->mti_stripe_index,
+ INDEX_MAP_SIZE * 8 - 1);
GOTO(out_up, rc = -ERANGE);
- }
+ }
if (test_bit(mti->mti_stripe_index, imap)) {
if ((mti->mti_flags & LDD_F_VIRGIN) &&
if (!mrul)
GOTO(out_close, rc = -ENOMEM);
/* devname is only needed information to replace UUID records */
- strncpy(mrul->target.mti_svname, devname, MTI_NAME_MAXLEN);
+ strlcpy(mrul->target.mti_svname, devname,
+ sizeof(mrul->target.mti_svname));
/* parse nids later */
- strncpy(mrul->target.mti_params, nids, MTI_PARAM_MAXLEN);
+ strlcpy(mrul->target.mti_params, nids, sizeof(mrul->target.mti_params));
/* Copy records to this temporary llog */
mrul->temp_llh = orig_llh;
}
/* write the lcfg in all logs for the given fs */
-int mgs_write_log_direct_all(const struct lu_env *env, struct mgs_device *mgs,
- struct fs_db *fsdb, struct mgs_target_info *mti,
- struct llog_cfg_rec *lcr, char *devname,
- char *comment, int server_only)
+static int mgs_write_log_direct_all(const struct lu_env *env,
+ struct mgs_device *mgs,
+ struct fs_db *fsdb,
+ struct mgs_target_info *mti,
+ struct llog_cfg_rec *lcr, char *devname,
+ char *comment, int server_only)
{
struct list_head log_list;
struct mgs_direntry *dirent, *n;
if (server_only && strstr(dirent->mde_name, "-client") != NULL)
goto next;
- if (strncmp(fsname, dirent->mde_name, len) != 0)
+ if (strlen(dirent->mde_name) <= len ||
+ strncmp(fsname, dirent->mde_name, len) != 0 ||
+ dirent->mde_name[len] != '-')
goto next;
CDEBUG(D_MGS, "Changing log %s\n", dirent->mde_name);
#07 L add_conn 0:OSC_uml1_ost1_mdsA 1:uml2_UUID
*/
- /* Pull failnid info out of params string */
+ /*
+ * Pull failnid info out of params string, which may contain something
+ * like "<nid1>,<nid2>:<nid3>,<nid4>". class_parse_nid() does not
+ * complain about abnormal inputs like ",:<nid1>", "<nid1>:,<nid2>",
+ * etc. However, convert_hostnames() should have caught those.
+ */
while (class_find_param(ptr, PARAM_FAILNODE, &ptr) == 0) {
while (class_parse_nid(ptr, &nid, &ptr) == 0) {
if (failnodeuuid == NULL) {
"client %s\n", libcfs_nid2str(nid),
failnodeuuid, cliname);
rc = record_add_uuid(env, llh, nid, failnodeuuid);
- }
+ /*
+ * If *ptr is ':', we have added all NIDs for
+ * failnodeuuid.
+ */
+ if (*ptr == ':') {
+ rc = record_add_conn(env, llh, cliname,
+ failnodeuuid);
+ name_destroy(&failnodeuuid);
+ failnodeuuid = NULL;
+ }
+ }
if (failnodeuuid) {
rc = record_add_conn(env, llh, cliname, failnodeuuid);
name_destroy(&failnodeuuid);
failnodeuuid = NULL;
}
- }
+ }
- return rc;
+ return rc;
}
static int mgs_write_log_mdc_to_lmv(const struct lu_env *env,
RETURN(-EINVAL);
} else {
/* assume devname is the fsname */
- memset(fsname, 0, MTI_NAME_MAXLEN);
- strncpy(fsname, devname, MTI_NAME_MAXLEN);
- fsname[MTI_NAME_MAXLEN - 1] = 0;
+ strlcpy(fsname, devname, MTI_NAME_MAXLEN);
}
CDEBUG(D_MGS, "setparam fs='%s' device='%s'\n", fsname, devname);
int mgs_nodemap_cmd(const struct lu_env *env, struct mgs_device *mgs,
enum lcfg_command_type cmd, const char *nodemap_name,
- const char *param)
+ char *param)
{
lnet_nid_t nid[2];
__u32 idmap[2];