35 if (m_ShutdownComplete)
36 return SyncStatus::Success;
40 return SyncStatus::IoError;
43 if (status != SyncStatus::Success)
45 if (!closeQuotaFiles(
false))
46 return SyncStatus::IoError;
52 if (status != SyncStatus::Success)
54 for (
auto it = m_InodeStates.
begin(); it != m_InodeStates.
end(); ++it) {
55 auto* state = it.value();
56 if (state->references || state->pageLoans || state->syncReferences || state->orphan)
57 return SyncStatus::IoError;
58 if (state->cache && !state->cache->fill.shutdown())
59 return SyncStatus::IoError;
61 for (
auto it = m_InodeStates.
begin(); it != m_InodeStates.
end(); ++it)
63 m_InodeStates.
clear();
65 return SyncStatus::IoError;
67 if (checkOptionalFeature(0x4) || checkRequiredFeature(~
size_t(0x2)) ||
68 checkReadOnlyFeature(~
size_t(0x3)))
69 return SyncStatus::Unsupported;
73 if (m_MountState != EXT2_STATE_CLEAN) {
74 m_ShutdownComplete =
true;
75 return SyncStatus::Success;
81 m_pSuperblock->s_state = HOST_TO_LITTLE16(m_MountState & ~EXT2_STATE_CLEAN);
84 ERROR(
"Ext2: could not restore the unchecked state after shutdown I/O failure");
85 return SyncStatus::IoError;
87 m_ShutdownComplete =
true;
88 return SyncStatus::Success;
117 return SyncStatus::Success;
119 return SyncStatus::IoError;
121 const auto quotaStatus = flushQuotas();
128 required = m_InodeStates.
count();
129 if (required <= snapshot.entries.size()) {
130 for (
auto it = m_InodeStates.
begin(); it != m_InodeStates.
end(); ++it) {
134 if (!state->references && !state->cache)
136 if (state->references == ~
size_t(0))
137 return SyncStatus::NoMemory;
139 __atomic_add_fetch(&state->syncReferences,
size_t(1), __ATOMIC_RELEASE);
140 snapshot.entries.pushBack({it.key(), state});
146 if (!snapshot.entries.tryReserve(required,
false))
147 return SyncStatus::NoMemory;
150 bool succeeded = quotaStatus == QuotaStatus::Success;
151 for (
const auto& entry : snapshot.entries) {
153 if (!entry.state->allocationValid)
155 if (entry.state->cache)
157 entry.state->cache->fill.syncAll(Ext2File::sharedFillBatchCallback, entry.state) &&
162#if THREADS || defined(STANDALONE_MUTEXES)
166 if (!flushAttributeWritesLocked())
167 return SyncStatus::IoError;
170 return succeeded ? SyncStatus::Success
171 : quotaStatus == QuotaStatus::NoMemory ? SyncStatus::NoMemory
172 : SyncStatus::IoError;