summaryrefslogtreecommitdiff
path: root/src/mongo/util
diff options
context:
space:
mode:
authormatt dannenberg <matt.dannenberg@10gen.com>2013-09-20 12:51:05 -0400
committermatt dannenberg <matt.dannenberg@10gen.com>2013-09-27 13:03:56 -0400
commit5356c87e34275379e0a9de2ff441055d0da0bf5f (patch)
treeb852c788c48b012c2ca6c37e2264887e7efe1dbc /src/mongo/util
parent8965a37fee24afc50919ba1df9c4952bec929ca2 (diff)
downloadmongo-5356c87e34275379e0a9de2ff441055d0da0bf5f.tar.gz
SERVER-8600 log warning for non-fsyncable filesystems
Diffstat (limited to 'src/mongo/util')
-rw-r--r--src/mongo/util/paths.cpp68
-rw-r--r--src/mongo/util/paths.h32
2 files changed, 73 insertions, 27 deletions
diff --git a/src/mongo/util/paths.cpp b/src/mongo/util/paths.cpp
new file mode 100644
index 00000000000..1924a26b4bd
--- /dev/null
+++ b/src/mongo/util/paths.cpp
@@ -0,0 +1,68 @@
+/* Copyright 2010 10gen Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mongo/util/paths.h"
+
+#include "mongo/platform/basic.h"
+#include "mongo/util/log.h"
+
+namespace mongo {
+
+ void flushMyDirectory(const boost::filesystem::path& file) {
+#ifdef __linux__ // this isn't needed elsewhere
+ static bool _warnedAboutFilesystem = false;
+ // if called without a fully qualified path it asserts; that makes mongoperf fail.
+ // so make a warning. need a better solution longer term.
+ // massert(13652, str::stream() << "Couldn't find parent dir for file: " << file.string(),);
+ if (!file.has_branch_path()) {
+ log() << "warning flushMyDirectory couldn't find parent dir for file: "
+ << file.string();
+ return;
+ }
+
+
+ boost::filesystem::path dir = file.branch_path(); // parent_path in new boosts
+
+ LOG(1) << "flushing directory " << dir.string();
+
+ int fd = ::open(dir.string().c_str(), O_RDONLY); // DO NOT THROW OR ASSERT BEFORE CLOSING
+ massert(13650, str::stream() << "Couldn't open directory '" << dir.string()
+ << "' for flushing: " << errnoWithDescription(),
+ fd >= 0);
+ if (fsync(fd) != 0) {
+ int e = errno;
+ if (e == EINVAL) { // indicates filesystem does not support synchronization
+ if (!_warnedAboutFilesystem) {
+ log() << "\tWARNING: This file system is not supported. For further information"
+ << " see:"
+ << startupWarningsLog;
+ log() << "\t\t\thttp://dochub.mongodb.org/core/unsupported-filesystems"
+ << startupWarningsLog;
+ log() << "\t\tPlease notify MongoDB, Inc. if an unlisted filesystem generated "
+ << "this warning." << startupWarningsLog;
+ _warnedAboutFilesystem = true;
+ }
+ }
+ else {
+ close(fd);
+ massert(13651, str::stream() << "Couldn't fsync directory '" << dir.string()
+ << "': " << errnoWithDescription(e),
+ false);
+ }
+ }
+ close(fd);
+#endif
+ }
+}
diff --git a/src/mongo/util/paths.h b/src/mongo/util/paths.h
index c75a7e4f737..9b59291e53a 100644
--- a/src/mongo/util/paths.h
+++ b/src/mongo/util/paths.h
@@ -18,12 +18,13 @@
#pragma once
-#include "mongoutils/str.h"
+#include <boost/filesystem/path.hpp>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <boost/filesystem/path.hpp>
+#include "mongo/util/log.h"
+#include "mongo/util/mongoutils/str.h"
namespace mongo {
@@ -51,7 +52,7 @@ namespace mongo {
string fullpath = f.string();
string relative = str::after(fullpath, dbp.string());
if( relative.empty() ) {
- log() << "warning file is not under db path? " << fullpath << ' ' << dbp.string() << endl;
+ log() << "warning file is not under db path? " << fullpath << ' ' << dbp.string();
RelativePath rp;
rp._p = fullpath;
return rp;
@@ -98,30 +99,7 @@ namespace mongo {
return dev1 == dev2;
}
- inline void flushMyDirectory(const boost::filesystem::path& file){
-#ifdef __linux__ // this isn't needed elsewhere
- // if called without a fully qualified path it asserts; that makes mongoperf fail. so make a warning. need a better solution longer term.
- // massert(13652, str::stream() << "Couldn't find parent dir for file: " << file.string(), );
- if( !file.has_branch_path() ) {
- log() << "warning flushMYDirectory couldn't find parent dir for file: " << file.string() << endl;
- return;
- }
-
-
- boost::filesystem::path dir = file.branch_path(); // parent_path in new boosts
-
- LOG(1) << "flushing directory " << dir.string() << endl;
-
- int fd = ::open(dir.string().c_str(), O_RDONLY); // DO NOT THROW OR ASSERT BEFORE CLOSING
- massert(13650, str::stream() << "Couldn't open directory '" << dir.string() << "' for flushing: " << errnoWithDescription(), fd >= 0);
- if (fsync(fd) != 0){
- int e = errno;
- close(fd);
- massert(13651, str::stream() << "Couldn't fsync directory '" << dir.string() << "': " << errnoWithDescription(e), false);
- }
- close(fd);
-#endif
- }
+ void flushMyDirectory(const boost::filesystem::path& file);
boost::filesystem::path ensureParentDirCreated(const boost::filesystem::path& p);