Whamcloud - gitweb
LU-5396 lod: (and mdt, mgs) make some symbols static
[fs/lustre-release.git] / lustre / mgs / mgs_llog.c
index 161d386..85a42a9 100644 (file)
@@ -27,7 +27,7 @@
  * 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/
@@ -559,13 +559,14 @@ static int mgs_set_index(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) &&
@@ -1441,10 +1442,12 @@ out_end:
 }
 
 /* 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;
@@ -1468,7 +1471,9 @@ int mgs_write_log_direct_all(const struct lu_env *env, struct mgs_device *mgs,
                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);
@@ -1883,7 +1888,12 @@ static int mgs_write_log_failnids(const struct lu_env *env,
         #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) {
@@ -1898,15 +1908,25 @@ static int mgs_write_log_failnids(const struct lu_env *env,
                                "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,
@@ -3956,7 +3976,7 @@ out:
 
 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];