git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] packfile: close and free packs upon releasing an object store

From
Jeff King <peff@peff.net>
Date
May 10, 2018, 05:12 UTC
Message-ID
<20180510051201.GB27259@sigill.intra.peff.net>
In-Reply-To
<20180510001211.163692-1-sbeller@google.com>
On Wed, May 09, 2018 at 05:12:10PM -0700, Stefan Beller wrote:
> In d0b59866223 (object-store: close all packs upon clearing the object
> store, 2018-03-23), we made sure to close all packfiles on releasing
> an object store, but we also have to free the memory of the closed packs.

I know we've assumed in a few places that a "struct packed_git" will never go away. The one that comes to mind is the mru list.

It looks like we'll be OK here:
Show 12 quoted lines
> diff --git a/object.c b/object.c
> index 66cffaf6e51..3e64a4a26dd 100644
> --- a/object.c
> +++ b/object.c
> @@ -485,6 +485,6 @@ void raw_object_store_clear(struct raw_object_store *o)
>  	o->alt_odb_tail = NULL;
>  
>  	INIT_LIST_HEAD(&o->packed_git_mru);
> -	close_all_packs(o);
> +	close_and_free_packs(o);
>  	o->packed_git = NULL;
>  }

because we clear the list above. But it would be dangerous for anybody else to call close_and_free_packs(). Should that INIT_LIST_HEAD get moved down into that function?

Probably the same applies to setting NULL here; you're left with a dangling pointer if you just call close_and_free_packs(). Should that helper maybe just be a static function in object.c?

Just brainstorming other places where the immutability of "struct packed_git" might be important:

  - pack-objects keeps a pointer from each object_entry to its
    containing packed_git. That's probably OK, as you wouldn't expect to
    be able to close the object store in the middle of that operation.
  - the reachability bitmap code holds a pointer to the pack that has a
    bitmap. Probably that whole "struct bitmap_index" needs to be part
    of the object_store (arguably it should all just be _inside_ the
    packed_git, but the current implementation avoids complexity by just
    having a single bitmap-per-repo).
-Peff
Previous: Stefan Beller
Message 3 of 3 in “packfile: close and free packs upon releasing an object store”
  1. 1/2 packfile: close and free packs upon releasing an object storeStefan Beller, May 10, 2018
  2. 2/2 packfile.h: remove all extern keywordsStefan Beller, May 10, 2018
  3. Jeff KingMay 10, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.