Fix relatime performance

This commit is contained in:
Sebastian Messmer 2017-08-24 08:19:16 +01:00
parent 0c3f16d0ce
commit fc21b0882a
3 changed files with 11 additions and 6 deletions

View File

@ -160,9 +160,10 @@ void DirBlob::statChildWithSizeAlreadySet(const Key &key, struct ::stat *result)
void DirBlob::updateAccessTimestampForChild(const Key &key, TimestampUpdateBehavior timestampUpdateBehavior) {
std::unique_lock<std::mutex> lock(_mutex);
_entries.updateAccessTimestampForChild(key, timestampUpdateBehavior);
if (_entries.updateAccessTimestampForChild(key, timestampUpdateBehavior)) {
_changed = true;
}
}
void DirBlob::updateModificationTimestampForChild(const Key &key) {
std::unique_lock<std::mutex> lock(_mutex);

View File

@ -228,7 +228,7 @@ void DirEntryList::setAccessTimes(const blockstore::Key &key, timespec lastAcces
found->setLastModificationTime(lastModificationTime);
}
void DirEntryList::updateAccessTimestampForChild(const blockstore::Key &key, TimestampUpdateBehavior timestampUpdateBehavior) {
bool DirEntryList::updateAccessTimestampForChild(const blockstore::Key &key, TimestampUpdateBehavior timestampUpdateBehavior) {
ASSERT(timestampUpdateBehavior == TimestampUpdateBehavior::RELATIME, "Currently only relatime supported");
auto found = _findByKey(key);
const timespec lastAccessTime = found->lastAccessTime();
@ -238,8 +238,12 @@ void DirEntryList::updateAccessTimestampForChild(const blockstore::Key &key, Tim
.tv_sec = now.tv_sec - 60*60*24,
.tv_nsec = now.tv_nsec
};
if (lastAccessTime < lastModificationTime || lastAccessTime < yesterday)
bool changed = false;
if (lastAccessTime < lastModificationTime || lastAccessTime < yesterday) {
found->setLastAccessTime(now);
changed = true;
}
return changed;
}
void DirEntryList::updateModificationTimestampForChild(const blockstore::Key &key) {

View File

@ -40,7 +40,7 @@ namespace cryfs {
void setMode(const blockstore::Key &key, mode_t mode);
bool setUidGid(const blockstore::Key &key, uid_t uid, gid_t gid);
void setAccessTimes(const blockstore::Key &key, timespec lastAccessTime, timespec lastModificationTime);
void updateAccessTimestampForChild(const blockstore::Key &key, TimestampUpdateBehavior timestampUpdateBehavior);
bool updateAccessTimestampForChild(const blockstore::Key &key, TimestampUpdateBehavior timestampUpdateBehavior);
void updateModificationTimestampForChild(const blockstore::Key &key);
private: