if (current)
scan_windows(current, &lru_p, &lru_w, &lru_l);
- for (p = current->repo->objects->packed_git; p; p = p->next)
+ for (p = current->repo->objects->packfiles->packs; p; p = p->next)
scan_windows(p, &lru_p, &lru_w, &lru_l);
if (lru_p) {
munmap(lru_w->base, lru_w->len);
void close_object_store(struct object_database *o)
{
struct odb_source *source;
- struct packed_git *p;
- for (p = o->packed_git; p; p = p->next)
- if (p->do_not_close)
- BUG("want to close pack marked 'do-not-close'");
- else
- close_pack(p);
+ packfile_store_close(o->packfiles);
for (source = o->sources; source; source = source->next) {
if (source->midx)
struct pack_window *mru_w = NULL;
int accept_windows_inuse = 1;
- for (p = r->objects->packed_git; p; p = p->next) {
+ for (p = r->objects->packfiles->packs; p; p = p->next) {
if (p->pack_fd == -1)
continue;
find_lru_pack(p, &lru_p, &mru_w, &accept_windows_inuse);
if (pack->pack_fd != -1)
pack_open_fds++;
- pack->next = r->objects->packed_git;
- r->objects->packed_git = pack;
+ pack->next = r->objects->packfiles->packs;
+ r->objects->packfiles->packs = pack;
hashmap_entry_init(&pack->packmap_ent, strhash(pack->pack_name));
hashmap_add(&r->objects->pack_map, &pack->packmap_ent);
count += m->num_objects;
}
- for (p = r->objects->packed_git; p; p = p->next) {
+ for (p = r->objects->packfiles->packs; p; p = p->next) {
if (open_pack_index(p))
continue;
count += p->num_objects;
static void rearrange_packed_git(struct repository *r)
{
- sort_packs(&r->objects->packed_git, sort_pack);
+ sort_packs(&r->objects->packfiles->packs, sort_pack);
}
static void prepare_packed_git_mru(struct repository *r)
INIT_LIST_HEAD(&r->objects->packed_git_mru);
- for (p = r->objects->packed_git; p; p = p->next)
+ for (p = r->objects->packfiles->packs; p; p = p->next)
list_add_tail(&p->mru, &r->objects->packed_git_mru);
}
struct packed_git *get_packed_git(struct repository *r)
{
prepare_packed_git(r);
- return r->objects->packed_git;
+ return r->objects->packfiles->packs;
}
struct multi_pack_index *get_multi_pack_index(struct odb_source *source)
prepare_midx_pack(m, i);
}
- return r->objects->packed_git;
+ return r->objects->packfiles->packs;
}
struct list_head *get_packed_git_mru(struct repository *r)
{
struct packed_git *p;
- for (p = r->objects->packed_git; p; p = p->next)
+ for (p = r->objects->packfiles->packs; p; p = p->next)
if (oidset_contains(&p->bad_objects, oid))
return p;
return NULL;
if (source->midx && fill_midx_entry(source->midx, oid, e))
return 1;
- if (!r->objects->packed_git)
+ if (!r->objects->packfiles->packs)
return 0;
list_for_each(pos, &r->objects->packed_git_mru) {
void packfile_store_free(struct packfile_store *store)
{
+ for (struct packed_git *p = store->packs, *next; p; p = next) {
+ next = p->next;
+ free(p);
+ }
free(store);
}
+
+void packfile_store_close(struct packfile_store *store)
+{
+ for (struct packed_git *p = store->packs; p; p = p->next) {
+ if (p->do_not_close)
+ BUG("want to close pack marked 'do-not-close'");
+ close_pack(p);
+ }
+}
*/
struct packfile_store {
struct object_database *odb;
+
+ /*
+ * The list of packfiles in the order in which they are being added to
+ * the store.
+ */
+ struct packed_git *packs;
};
/*
struct packfile_store *packfile_store_new(struct object_database *odb);
/*
- * Free the packfile store and all its associated state.
+ * Free the packfile store and all its associated state. All packfiles
+ * tracked by the store will be closed.
*/
void packfile_store_free(struct packfile_store *store);
+/*
+ * Close all packfiles associated with this store. The packfiles won't be
+ * free'd, so they can be re-opened at a later point in time.
+ */
+void packfile_store_close(struct packfile_store *store);
+
static inline int pack_map_entry_cmp(const void *cmp_data UNUSED,
const struct hashmap_entry *entry,
const struct hashmap_entry *entry2,