From 4e66a3b98de3c55096b33e273cf9a0ddb93a0832 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 9 Jul 2012 18:16:44 -0700 Subject: [PATCH] mkcephfs: error out if mon data directory is not empty The ceph-mon --mkfs function no longer wipes out the directory; it is in fact mostly a no-op that just verifies the dir exists. So, ensure that the directory is empty at mkfs time. This could alternatively do an 'rm -r' in that directory (that is in fact what ceph-mon used to do), but this is safer. Signed-off-by: Sage Weil --- src/mkcephfs.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mkcephfs.in b/src/mkcephfs.in index 17b6014474d..aa8eee15efe 100644 --- a/src/mkcephfs.in +++ b/src/mkcephfs.in @@ -266,6 +266,12 @@ if [ -n "$initdaemon" ]; then fi if [ $type = "mon" ]; then + get_conf mon_data "/var/run/ceph/mon/ceph-$id" "mon data" + if [ `ls $mon_data | wc -l` -ne 0 ]; then + echo "ERROR: $name mon_data directory $mon_data is not empty." + echo " Please make sure that it is empty before running mkcephfs." + exit 1 + fi $BINDIR/ceph-mon -c $conf --mkfs -i $id --monmap $dir/monmap --osdmap $dir/osdmap -k $dir/keyring.mon fi