]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: roll mkmonfs functionality into cmon --mkfs
authorSage Weil <sage@newdream.net>
Mon, 24 May 2010 22:28:59 +0000 (15:28 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Mon, 24 May 2010 22:56:02 +0000 (15:56 -0700)
debian/ceph.install
src/Makefile.am
src/cmon.cc
src/mkcephfs.in
src/mkmonfs.cc [deleted file]
src/vstart.sh

index ef27edae178f5d89a910ab0e59bfe0efb7245d9c..c633e4f431951e85cd8a3635e54ae95fcce49a93 100644 (file)
@@ -8,7 +8,6 @@ usr/bin/crun
 usr/bin/cmon
 usr/bin/cmds
 usr/bin/cosd
-usr/bin/mkmonfs
 usr/bin/cauthtool
 usr/bin/rados
 usr/bin/rbdtool
index 324662e0425e695a34bce69d98c8fb76d1af6f80..2b4e7b28f42201d2f57664924c57f2227e7f2567 100644 (file)
@@ -27,13 +27,11 @@ bin_PROGRAMS += cmds
 # admin tools
 ceph_SOURCES = ceph.cc msg/SimpleMessenger.cc
 ceph_LDADD = libcrush.a libcommon.a -ledit -lpthread -lm -lcrypto
-mkmonfs_SOURCES = mkmonfs.cc
-mkmonfs_LDADD = libmon.a libcrush.a libcommon.a -lpthread -lm -lcrypto
 cconf_SOURCES = cconf.cc
 cconf_LDADD = libcommon.a -lpthread -lm -lcrypto
 cauthtool_SOURCES = cauthtool.cc
 cauthtool_LDADD = libcommon.a -lpthread -lm -lcrypto
-bin_PROGRAMS += ceph mkmonfs cconf cauthtool
+bin_PROGRAMS += ceph cconf cauthtool
 
 monmaptool_SOURCES = monmaptool.cc
 monmaptool_LDADD = libcommon.a -lpthread -lm -lcrypto
@@ -47,7 +45,7 @@ mount_ceph_SOURCES = mount/mount.ceph.c
 noinst_PROGRAMS = mount.ceph
 
 
-core: cmon cosd cmds mkmonfs ceph cconf monmaptool osdmaptool crushtool
+core: cmon cosd cmds ceph cconf monmaptool osdmaptool crushtool
 
 
 dumpjournal_SOURCES = dumpjournal.cc msg/SimpleMessenger.cc
@@ -750,7 +748,7 @@ noinst_HEADERS = \
        rgw/rgw_user.h\
        sample.ceph.conf
 
-all_sources = $(cmon_SOURCES) $(ceph_SOURCES) $(mkmonfs_SOURCES) $(cauthtool_SOURCES) $(monmaptool_SOURCES) \
+all_sources = $(cmon_SOURCES) $(ceph_SOURCES) $(cauthtool_SOURCES) $(monmaptool_SOURCES) \
        $(crushtool_SOURCES) $(osdmaptool_SOURCES) $(cconf_SOURCES) $(mount_ceph_SOURCES) $(cmds_SOURCES) \
        $(dumpjournal_SOURCES) $(cosd_SOURCES) $(dupstore_SOURCES) $(streamtest_SOURCES) $(csyn_SOURCES)  \
        $(testmsgr_SOURCES) $(cfuse_SOURCES) $(fakefuse_SOURCES) $(psim_SOURCES) \
index 7fafe41f193c89933b1c8b0d5960919553589ccd..530c2833f03a45b51fb3c18962a8b380b4413825 100644 (file)
@@ -43,18 +43,33 @@ void usage()
   cerr << "usage: cmon -i monid [--mon-data=pathtodata] [flags]" << std::endl;
   cerr << "  --debug_mon n\n";
   cerr << "        debug monitor level (e.g. 10)\n";
+  cerr << "  --mkfs\n";
+  cerr << "        build fresh monitor fs\n";
   generic_server_usage();
 }
 
 int main(int argc, const char **argv) 
 {
   int err;
+  DEFINE_CONF_VARS(usage);
+
+  bool mkfs = false;
+  const char *osdmapfn = 0;
 
   vector<const char*> args;
   argv_to_vec(argc, argv, args);
   env_to_vec(args);
   common_init(args, "mon", true, true);
 
+  FOR_EACH_ARG(args) {
+    if (CONF_ARG_EQ("mkfs", '\0')) {
+      mkfs = true;
+    } else if (CONF_ARG_EQ("osdmap", '\0')) {
+      CONF_SAFE_SET_ARG_VAL(&osdmapfn, OPT_STR);
+    } else
+      usage();
+  }
+
   // whoami
   char *end;
   int whoami = strtol(g_conf.id, &end, 10);
@@ -68,6 +83,42 @@ int main(int argc, const char **argv)
     usage();
   }
 
+  // -- mkfs --
+  if (mkfs) {
+    if (!g_conf.monmap || !osdmapfn)
+      usage();
+
+    // make sure it doesn't already exist
+        /*
+    struct stat st;
+    if (::lstat(g_conf.mon_data, &st) == 0) {
+      cerr << "monfs dir " << g_conf.mon_data << " already exists; remove it first" << std::endl;
+      usage();
+    }
+       */
+
+    // load monmap
+    bufferlist monmapbl, osdmapbl;
+    int err = monmapbl.read_file(g_conf.monmap);
+    if (err < 0)
+      exit(1);
+    MonMap monmap;
+    monmap.decode(monmapbl);
+    
+    err = osdmapbl.read_file(osdmapfn);
+    if (err < 0)
+      exit(1);
+
+    // go
+    MonitorStore store(g_conf.mon_data);
+    Monitor mon(whoami, &store, 0, &monmap);
+    mon.mkfs(osdmapbl);
+    cout << argv[0] << ": created monfs at " << g_conf.mon_data 
+        << " for mon" << whoami
+        << std::endl;
+    return 0;
+  }
+
   if (g_conf.clock_tare) g_clock.tare();
 
   CompatSet mon_features(ceph_mon_feature_compat,
index 5f11c33c076831b88988b178b4bfcbf44b7c5b00..0f9a39c3fce31e9d251b87bd863cce3c8968a6be 100644 (file)
@@ -205,7 +205,7 @@ for name in $what; do
            [ -n "$user" ] && chown $user $tmpkeyring
        fi
        get_conf mon_data "" "mon data"
-       do_cmd "$BINDIR/mkmonfs --clobber --mon-data $mon_data -i $num --monmap $monmap --osdmap $osdmap -k $tmpkeyring ; rm -f $tmpkeyring"
+       do_cmd "$BINDIR/cmon --mkfs -i $num --monmap $monmap --osdmap $osdmap -k $tmpkeyring ; rm -f $tmpkeyring"
 
        if [ -n "$ssh" ]; then
            if [ -n "$user" ]; then
diff --git a/src/mkmonfs.cc b/src/mkmonfs.cc
deleted file mode 100644 (file)
index fd2cff9..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
-// vim: ts=8 sw=2 smarttab
-/*
- * Ceph - scalable distributed file system
- *
- * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
- * Foundation.  See file COPYING.
- * 
- */
-
-#include "common/common_init.h"
-#include "mon/MonitorStore.cc"
-#include "config.h"
-
-#include "mon/Monitor.h"
-#include "mon/MonMap.h"
-#include "mds/MDSMap.h"
-#include "osd/OSDMap.h"
-#include "mon/PGMap.h"
-#include "common/common_init.h"
-
-void usage() 
-{
-  cerr << "usage: ./mkmonfs [--clobber] --mon-data <monfsdir> -i <monid> --monmap <file> --osdmap <file>" << std::endl;
-  exit(1);
-}
-
-
-int main(int argc, const char **argv)
-{
-  vector<const char*> args;
-  argv_to_vec(argc, argv, args);
-  DEFINE_CONF_VARS(usage);
-  common_init(args, "mon", false, false);
-
-  bool clobber = false;
-  int whoami = -1;
-  const char *osdmapfn = 0;
-
-  FOR_EACH_ARG(args) {
-    if (CONF_ARG_EQ("clobber", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&clobber, OPT_BOOL);
-    } else if (CONF_ARG_EQ("mon", 'i')) {
-      CONF_SAFE_SET_ARG_VAL(&whoami, OPT_INT);
-    } else if (CONF_ARG_EQ("osdmap", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&osdmapfn, OPT_STR);
-    } else {
-      usage();
-    }
-  }
-  if (!g_conf.mon_data || !g_conf.monmap || whoami < 0)
-    usage();
-
-  if (!clobber) {
-    // make sure it doesn't exist
-    struct stat st;
-    if (::lstat(g_conf.mon_data, &st) == 0) {
-      cerr << "monfs dir " << g_conf.mon_data << " already exists; remove it first" << std::endl;
-      usage();
-    }
-  }
-
-  // load monmap
-  bufferlist monmapbl, osdmapbl;
-  int err = monmapbl.read_file(g_conf.monmap);
-  if (err < 0)
-    exit(1);
-  MonMap monmap;
-  monmap.decode(monmapbl);
-
-  err = osdmapbl.read_file(osdmapfn);
-  if (err < 0)
-    exit(1);
-
-  // go
-  MonitorStore store(g_conf.mon_data);
-  Monitor mon(whoami, &store, 0, &monmap);
-  mon.mkfs(osdmapbl);
-  cout << argv[0] << ": created monfs at " << g_conf.mon_data 
-       << " for mon" << whoami
-       << std::endl;
-  return 0;
-}
index 8c7ffca90731fe4d9ca7e14e86374605cf33df8d..ec36fbef0c3324938c05e0f3b0cfbe88793dac5d 100755 (executable)
@@ -302,7 +302,7 @@ EOF
 
                for f in `seq 0 $((CEPH_NUM_MON-1))`
                do
-                   cmd="$CEPH_BIN/mkmonfs -c $conf --clobber --mon-data=dev/mon$f -i $f --monmap=$monmap_fn --osdmap=$osdmap_fn"
+                   cmd="$CEPH_BIN/cmon --mkfs -c $conf -i $f --monmap=$monmap_fn --osdmap=$osdmap_fn"
                    [ "$cephx" -eq 1 ] && cmd="$cmd --keyring=$keyring_fn"
                    echo $cmd
                    $cmd