Mesa (main): util/fossilize_db: Only lock the db file, not the index.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Jun 21 10:27:39 UTC 2021
Module: Mesa
Branch: main
Commit: d074cc4af492950273960cef723c3813cff5231e
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d074cc4af492950273960cef723c3813cff5231e
Author: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Date: Sun Jun 20 01:15:29 2021 +0200
util/fossilize_db: Only lock the db file, not the index.
This thing is entirely opt-in wrt caring about it when writing to
a file anyway. Since we also lock the two at the same time and they
have an 1-1 relation we can just lock one of the two files. Saves
some syscalls.
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11485>
---
src/util/fossilize_db.c | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/src/util/fossilize_db.c b/src/util/fossilize_db.c
index 37f1d4ccacb..8b122aa492f 100644
--- a/src/util/fossilize_db.c
+++ b/src/util/fossilize_db.c
@@ -211,10 +211,6 @@ load_foz_dbs(struct foz_db *foz_db, FILE *db_idx, uint8_t file_idx,
if (err == -1)
goto fail;
- err = lock_file_with_timeout(db_idx, 100000000);
- if (err == -1)
- goto fail;
-
/* Compute length again so we know nobody else did it in the meantime */
fseek(db_idx, 0, SEEK_END);
len = ftell(db_idx);
@@ -248,7 +244,6 @@ load_foz_dbs(struct foz_db *foz_db, FILE *db_idx, uint8_t file_idx,
goto fail;
}
- flock(fileno(db_idx), LOCK_UN);
flock(fileno(foz_db->file[file_idx]), LOCK_UN);
update_foz_index(foz_db, db_idx, file_idx);
@@ -257,7 +252,6 @@ load_foz_dbs(struct foz_db *foz_db, FILE *db_idx, uint8_t file_idx,
return true;
fail:
- flock(fileno(db_idx), LOCK_UN);
flock(fileno(foz_db->file[file_idx]), LOCK_UN);
foz_destroy(foz_db);
return false;
@@ -441,10 +435,6 @@ foz_write_entry(struct foz_db *foz_db, const uint8_t *cache_key_160bit,
if (err == -1)
goto fail_file;
- err = lock_file_with_timeout(foz_db->db_idx, 1000000000);
- if (err == -1)
- goto fail_file;
-
simple_mtx_lock(&foz_db->mtx);
update_foz_index(foz_db, foz_db->db_idx, 0);
@@ -514,7 +504,6 @@ foz_write_entry(struct foz_db *foz_db, const uint8_t *cache_key_160bit,
_mesa_hash_table_u64_insert(foz_db->index_db, hash, entry);
simple_mtx_unlock(&foz_db->mtx);
- flock(fileno(foz_db->db_idx), LOCK_UN);
flock(fileno(foz_db->file[0]), LOCK_UN);
return true;
@@ -522,7 +511,6 @@ foz_write_entry(struct foz_db *foz_db, const uint8_t *cache_key_160bit,
fail:
simple_mtx_unlock(&foz_db->mtx);
fail_file:
- flock(fileno(foz_db->db_idx), LOCK_UN);
flock(fileno(foz_db->file[0]), LOCK_UN);
return false;
}
More information about the mesa-commit
mailing list