backingstore: rename refresh method to flush

Summary:
The intent behind the refresh method is to both read new data from the disk,
but also to flush the in-memory write buffer to disk. The name "flush" is used
in the revisionstore code to mean the latter, thus let's use "flush" in the
rest of the codebase.

Reviewed By: kmancini

Differential Revision: D30947873

fbshipit-source-id: c85a6abe770a47d6ce454d6af1fa73e505194a22
This commit is contained in:
Xavier Deguillard 2021-09-21 09:36:09 -07:00 committed by Facebook GitHub Bot
parent d5acd57947
commit e9de9e1fe5
10 changed files with 25 additions and 19 deletions

View File

@ -770,7 +770,7 @@ HgBackingStore::getLiveImportWatches(HgImportObject object) const {
}
void HgBackingStore::periodicManagementTask() {
datapackStore_.refresh();
datapackStore_.flush();
}
} // namespace facebook::eden

View File

@ -225,7 +225,7 @@ std::unique_ptr<Tree> HgDatapackStore::getTree(
if (!tree && local_only) {
// Mercurial might have just written the tree to the store. Refresh the
// store and try again, this time allowing remote fetches.
store_.refresh();
store_.flush();
tree = store_.getTree(manifestId.getBytes(), false);
}
if (tree) {
@ -234,8 +234,8 @@ std::unique_ptr<Tree> HgDatapackStore::getTree(
return nullptr;
}
void HgDatapackStore::refresh() {
store_.refresh();
void HgDatapackStore::flush() {
store_.flush();
}
} // namespace facebook::eden

View File

@ -61,7 +61,13 @@ class HgDatapackStore {
const Hash& edenTreeId,
LocalStore::WriteBatch* writeBatch);
void refresh();
/**
* Flush any pending writes to disk.
*
* As a side effect, this also reloads the current state of Mercurial's
* cache, picking up any writes done by Mercurial.
*/
void flush();
private:
HgNativeBackingStore store_;

View File

@ -271,10 +271,10 @@ std::shared_ptr<RustTree> HgNativeBackingStore::getTree(
return manifest.unwrap();
}
void HgNativeBackingStore::refresh() {
XLOG(DBG7) << "Refreshing backing store";
void HgNativeBackingStore::flush() {
XLOG(DBG7) << "Flushing backing store";
rust_backingstore_refresh(store_.get());
rust_backingstore_flush(store_.get());
}
} // namespace facebook::eden

View File

@ -50,7 +50,7 @@ class HgNativeBackingStore {
std::shared_ptr<RustTree> getTree(folly::ByteRange node, bool local);
void refresh();
void flush();
private:
std::unique_ptr<RustBackingStore, std::function<void(RustBackingStore*)>>

View File

@ -7,7 +7,7 @@
* This file is generated with cbindgen. Please run `./tools/cbindgen.sh` to
* update this file.
*
* @generated SignedSource<<d55c0fa3a07268a77cb8b9aee5ec761e>>
* @generated SignedSource<<50807b13cfd41d6c06ab43ae99fb8ea1>>
*
*/
@ -160,7 +160,7 @@ void rust_backingstore_get_tree_batch(RustBackingStore *store,
void rust_tree_free(RustTree *tree);
void rust_backingstore_refresh(RustBackingStore *store);
void rust_backingstore_flush(RustBackingStore *store);
void rust_cbytes_free(RustCBytes *vec);

View File

@ -240,7 +240,7 @@ impl BackingContentStores {
/// Forces backing store to rescan pack files or local indexes
#[instrument(level = "debug", skip(self))]
pub fn refresh(&self) {
pub fn flush(&self) {
self.blobstore.refresh().ok();
self.treestore.as_content_store().refresh().ok();
}

View File

@ -82,10 +82,10 @@ impl BackingStore {
/// Forces backing store to write its pending data to disk and to read the latest version from
/// the disk.
pub fn refresh(&self) {
pub fn flush(&self) {
match self {
Old(stores) => stores.refresh(),
New(stores) => stores.refresh(),
Old(stores) => stores.flush(),
New(stores) => stores.flush(),
}
}
}
@ -93,6 +93,6 @@ impl BackingStore {
impl Drop for BackingStore {
fn drop(&mut self) {
// Make sure that all the data that was fetched is written to the hgcache.
self.refresh();
self.flush();
}
}

View File

@ -264,7 +264,7 @@ impl BackingScmStores {
/// Forces backing store to rescan pack files or local indexes
#[instrument(level = "debug", skip(self))]
pub fn refresh(&self) {
pub fn flush(&self) {
self.filestore.refresh().ok();
self.treestore.refresh().ok();
}

View File

@ -170,9 +170,9 @@ pub extern "C" fn rust_tree_free(tree: *mut Tree) {
}
#[no_mangle]
pub extern "C" fn rust_backingstore_refresh(store: *mut BackingStore) {
pub extern "C" fn rust_backingstore_flush(store: *mut BackingStore) {
assert!(!store.is_null());
let store = unsafe { &*store };
store.refresh();
store.flush();
}