diff --git a/ChangeLog.txt b/ChangeLog.txt index faa7aa94..250b945e 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -8,7 +8,10 @@ Other changes: * Now requires CMake 3.6 or later New features: -* Add support for atime mount options (noatime, strictatime, relatime, atime, nodiratime). As before, relatime is the default. +* Add support for atime mount options (noatime, strictatime, relatime, atime, nodiratime). +* The default is atime behavior is now *noatime* (in 0.10.x is was relatime). + Noatime reduces the amount of write necessary and with that reduces the probability for synchronization conflicts + or corrupted file systems if a power outage happens while writing. * Add an --immediate flag to cryfs-unmount that tries to unmount immediately and doesn't wait for processes to release their locks on the file system. diff --git a/src/fspp/fuse/Fuse.cpp b/src/fspp/fuse/Fuse.cpp index 758d660b..ac976080 100644 --- a/src/fspp/fuse/Fuse.cpp +++ b/src/fspp/fuse/Fuse.cpp @@ -371,8 +371,8 @@ void Fuse::_createContext(const vector &fuseOptions) { const bool has_strictatime_flag = fuseOptions.end() != std::find(fuseOptions.begin(), fuseOptions.end(), "strictatime"); const bool has_nodiratime_flag = fuseOptions.end() != std::find(fuseOptions.begin(), fuseOptions.end(), "nodiratime"); - // Default is RELATIME - _context = Context(relatime()); + // Default is NOATIME, this reduces the probability for synchronization conflicts + _context = Context(noatime()); if (has_noatime_flag) { ASSERT(!has_atime_flag, "Cannot have both, noatime and atime flags set."); @@ -412,7 +412,7 @@ void Fuse::_createContext(const vector &fuseOptions) { ASSERT(!has_atime_flag, "This shouldn't happen, or we would have hit a case above"); ASSERT(!has_relatime_flag, "This shouldn't happen, or we would have hit a case above"); ASSERT(!has_strictatime_flag, "This shouldn't happen, or we would have hit a case above"); - _context->setTimestampUpdateBehavior(nodiratime_relatime()); // use relatime by default + _context->setTimestampUpdateBehavior(noatime()); // use noatime by default } } diff --git a/test/fspp/fuse/TimestampTest.cpp b/test/fspp/fuse/TimestampTest.cpp index 71e5dc43..3d6c5ca6 100644 --- a/test/fspp/fuse/TimestampTest.cpp +++ b/test/fspp/fuse/TimestampTest.cpp @@ -10,7 +10,7 @@ typedef FuseTest FuseTimestampTest; TEST_F(FuseTimestampTest, whenCalledWithoutAnyAtimeFlag_thenHasRelatimeBehavior) { auto fs = TestFS({}); - EXPECT_EQ(fspp::relatime().get(), context().timestampUpdateBehavior().get()); + EXPECT_EQ(fspp::noatime().get(), context().timestampUpdateBehavior().get()); } TEST_F(FuseTimestampTest, whenCalledWithNoatimeFlag_thenHasNoatimeBehavior) { @@ -33,9 +33,10 @@ TEST_F(FuseTimestampTest, whenCalledWithAtimeFlag_thenHasRelatimeBehavior) { EXPECT_EQ(fspp::relatime().get(), context().timestampUpdateBehavior().get()); } -TEST_F(FuseTimestampTest, whenCalledWithNodiratimeFlag_thenHasNodiratimeRelatimeBehavior) { +TEST_F(FuseTimestampTest, whenCalledWithNodiratimeFlag_thenHasNoatimeBehavior) { + // note: this behavior is correct because "noatime" is default and adding "nodiratime" doesn't change anything. auto fs = TestFS({"-o", "nodiratime"}); - EXPECT_EQ(fspp::nodiratime_relatime().get(), context().timestampUpdateBehavior().get()); + EXPECT_EQ(fspp::noatime().get(), context().timestampUpdateBehavior().get()); } @@ -302,12 +303,14 @@ TEST_F(FuseTimestampTest, whenCalledWithNodiratimeStrictatimeFlag_withSeparateFl EXPECT_EQ(fspp::nodiratime_strictatime().get(), context().timestampUpdateBehavior().get()); } -TEST_F(FuseTimestampTest, whenCalledWithNodiratimeNodiratimeFlag_withCsv_thenHasNodiratimeRelatimeBehavior) { +TEST_F(FuseTimestampTest, whenCalledWithNodiratimeNodiratimeFlag_withCsv_thenHasNoatimeBehavior) { + // note: this behavior is correct because "noatime" is default and adding "nodiratime" doesn't change anything. auto fs = TestFS({"-o", "nodiratime,nodiratime"}); - EXPECT_EQ(fspp::nodiratime_relatime().get(), context().timestampUpdateBehavior().get()); + EXPECT_EQ(fspp::noatime().get(), context().timestampUpdateBehavior().get()); } -TEST_F(FuseTimestampTest, whenCalledWithNodiratimeNodiratimeFlag_withSeparateFlags_thenHasNodiratimeRelatimeBehavior) { +TEST_F(FuseTimestampTest, whenCalledWithNodiratimeNodiratimeFlag_withSeparateFlags_thenHasNoatimeBehavior) { + // note: this behavior is correct because "noatime" is default and adding "nodiratime" doesn't change anything. auto fs = TestFS({"-o", "nodiratime", "-o", "nodiratime"}); - EXPECT_EQ(fspp::nodiratime_relatime().get(), context().timestampUpdateBehavior().get()); + EXPECT_EQ(fspp::noatime().get(), context().timestampUpdateBehavior().get()); }