Whamcloud - gitweb
LU-7160 mgs: Skip processing .bak files on MGS
[fs/lustre-release.git] / lustre / mgs / mgs_llog.c
index e48f888..e307e16 100644 (file)
@@ -100,6 +100,15 @@ int class_dentry_readdir(const struct lu_env *env,
                                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;
@@ -114,7 +123,8 @@ int class_dentry_readdir(const struct lu_env *env,
 next:
                rc = iops->next(env, it);
        } while (rc == 0);
-       rc = 0;
+       if (rc > 0)
+               rc = 0;
 
        iops->put(env, it);
 
@@ -2293,34 +2303,34 @@ static int mgs_write_log_mdt(const struct lu_env *env,
         #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);
@@ -2335,8 +2345,34 @@ static int mgs_write_log_mdt(const struct lu_env *env,
                        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);
@@ -2579,7 +2615,7 @@ out_end:
                        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);
@@ -3686,40 +3722,6 @@ end:
         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;
-}
-
 int mgs_write_log_target(const struct lu_env *env, struct mgs_device *mgs,
                         struct mgs_target_info *mti, struct fs_db *fsdb)
 {
@@ -3745,6 +3747,9 @@ 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 &
@@ -4133,6 +4138,10 @@ int mgs_nodemap_cmd(const struct lu_env *env, struct mgs_device *mgs,
                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);
@@ -4169,6 +4178,9 @@ int mgs_nodemap_cmd(const struct lu_env *env, struct mgs_device *mgs,
                        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;
        }