Re: [PATCH 02/10] struct ref_transaction: add a place for backends to store data
- From
Michael Haggerty <mhagger@alum.mit.edu>
- Date
- Sep 8, 2017, 08:19 UTC
- Message-ID
- <6c4cf1eb-7991-1a39-a298-7839872ed3f5@alum.mit.edu>
- In-Reply-To
- <20170908070205.3hwa7tjgok7kgknc@sigill.intra.peff.net>
On 09/08/2017 09:02 AM, Jeff King wrote:
Show 23 quoted lines
> On Tue, Aug 29, 2017 at 10:20:26AM +0200, Michael Haggerty wrote:
>
>> `packed_ref_store` is going to want to store some transaction-wide
>> data, so make a place for it.
>
> That makes sense, although...
>
>> diff --git a/refs/refs-internal.h b/refs/refs-internal.h
>> index b02dc5a7e3..d7d344de73 100644
>> --- a/refs/refs-internal.h
>> +++ b/refs/refs-internal.h
>> @@ -242,6 +242,7 @@ struct ref_transaction {
>> size_t alloc;
>> size_t nr;
>> enum ref_transaction_state state;
>> + void *backend_data;
>> };
>
> This is just one pointer. Once we start layering ref backends (and
> already we're moving towards a "files" layer which sits atop loose and
> packed backends, right?), how do we avoid backends stomping on each
> other (or worse, dereferencing somebody else's data as their own
> struct)?My conception is that layered backends would be separated as much as possible, and if the "top" layer needs to modify the "bottom" layer, it would do so via a separate reference transaction on the bottom layer. That transaction would be owned by the bottom layer, which would be able to use the corresponding `backend_data` pointers however it likes.
You can see an example of this construct in patch 08.
Michael