Not all flush will write to disk
This commit is contained in:
parent
0613a149a6
commit
315557f58f
|
@ -19,7 +19,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "fdbrpc/AsyncFileCached.actor.h"
|
#include "fdbrpc/AsyncFileCached.actor.h"
|
||||||
#include "flow/actorcompiler.h" // This must be the last #include.
|
|
||||||
|
|
||||||
//Page caches used in non-simulated environments
|
//Page caches used in non-simulated environments
|
||||||
Optional<Reference<EvictablePageCache>> pc4k, pc64k;
|
Optional<Reference<EvictablePageCache>> pc4k, pc64k;
|
||||||
|
@ -253,33 +252,23 @@ Future<Void> AsyncFileCached::changeFileSize( int64_t size ) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ACTOR static Future<Void> flushActor(AsyncFileCached* self) {
|
|
||||||
state std::vector<Future<Void>> unflushed;
|
|
||||||
state int debug_count = self->getFlushable().size();
|
|
||||||
state int i = 0;
|
|
||||||
state AFCPage* p;
|
|
||||||
|
|
||||||
for (; i < self->getFlushable().size();) {
|
|
||||||
p = self->getFlushable()[i];
|
|
||||||
// Wait for rate control if it is set
|
|
||||||
if (self->getRateControl()) wait(self->getRateControl()->getAllowance(1));
|
|
||||||
auto f = p->flush();
|
|
||||||
if (!f.isReady() || f.isError()) unflushed.push_back( f );
|
|
||||||
ASSERT((i < self->getFlushable().size() && self->getFlushable()[i] == p) != f.isReady());
|
|
||||||
if (!f.isReady()) i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASSERT(self->getFlushable().size() <= debug_count);
|
|
||||||
wait(waitForAll(unflushed));
|
|
||||||
|
|
||||||
return Void();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<Void> AsyncFileCached::flush() {
|
Future<Void> AsyncFileCached::flush() {
|
||||||
++countFileCacheWrites;
|
++countFileCacheWrites;
|
||||||
++countCacheWrites;
|
++countCacheWrites;
|
||||||
|
|
||||||
return flushActor(this);
|
std::vector<Future<Void>> unflushed;
|
||||||
|
|
||||||
|
int debug_count = flushable.size();
|
||||||
|
for(int i=0; i<flushable.size(); ) {
|
||||||
|
auto p = flushable[i];
|
||||||
|
auto f = p->flush();
|
||||||
|
if (!f.isReady() || f.isError()) unflushed.push_back( f );
|
||||||
|
ASSERT( (i<flushable.size() && flushable[i] == p) != f.isReady() );
|
||||||
|
if (!f.isReady()) i++;
|
||||||
|
}
|
||||||
|
ASSERT( flushable.size() <= debug_count );
|
||||||
|
|
||||||
|
return waitForAll(unflushed);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Void> AsyncFileCached::quiesce() {
|
Future<Void> AsyncFileCached::quiesce() {
|
||||||
|
|
|
@ -512,6 +512,10 @@ struct AFCPage : public EvictablePage, public FastAllocated<AFCPage> {
|
||||||
wait( self->notReading && self->notFlushing );
|
wait( self->notReading && self->notFlushing );
|
||||||
|
|
||||||
if (dirty) {
|
if (dirty) {
|
||||||
|
// Wait for rate control if it is set
|
||||||
|
if (self->owner->getRateControl())
|
||||||
|
wait(self->owner->getRateControl()->getAllowance(1));
|
||||||
|
|
||||||
if ( self->pageOffset + self->pageCache->pageSize > self->owner->length ) {
|
if ( self->pageOffset + self->pageCache->pageSize > self->owner->length ) {
|
||||||
ASSERT(self->pageOffset < self->owner->length);
|
ASSERT(self->pageOffset < self->owner->length);
|
||||||
memset( static_cast<uint8_t *>(self->data) + self->owner->length - self->pageOffset, 0, self->pageCache->pageSize - (self->owner->length - self->pageOffset) );
|
memset( static_cast<uint8_t *>(self->data) + self->owner->length - self->pageOffset, 0, self->pageCache->pageSize - (self->owner->length - self->pageOffset) );
|
||||||
|
|
Loading…
Reference in New Issue