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

Re: [RFC PATCH 1/2] reftable: remove the "return_block" abstraction

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 25, 2022, 17:30 UTC
Message-ID
<xmqqilqxvzoa.fsf@gitster.g>
In-Reply-To
<CAFQ2z_O7ytx=AsXuJbYnOdMwT0u03sMP-ZjRRjt4HFn48HT-2g@mail.gmail.com>
Han-Wen Nienhuys <hanwen@google.com> writes:
Show 22 quoted lines
> On Fri, Apr 15, 2022 at 12:21 PM Ævar Arnfjörð Bjarmason
> <avarab@gmail.com> wrote:
>>
>> This abstraction added in 1214aa841bc (reftable: add blocksource, an
>> abstraction for random access reads, 2021-10-07) has the caller
>> provide a "blockp->data", so there's not point in having the vtable
>> have a custom free() function.
>>
>> In addition this had what looked like a poor man's SANITIZE=address
>> doing a memset() to 0xff just before the data was free'd.
>
>>  void reftable_block_done(struct reftable_block *blockp)
>>  {
>> -       struct reftable_block_source source = blockp->source;
>> -       if (blockp && source.ops)
>> -               source.ops->return_block(source.arg, blockp);
>> +       FREE_AND_NULL(blockp->data);
>
>
> My thinking here is that we could mmap the reftable file to do reads.
> In that case, discarding the block would imply decreasing a refcount
> somewhere, rather than deallocating memory.

Sounds like a plan. As a solution to the memset() thing, ripping out this abstraction layer is indeed not just overkill but also doing too much of "while we are at it".

Let's take what we've queued on cm/reftable-0-length-memset and merge it down.

Thanks.
Previous: Han-Wen NienhuysNext: Ævar Arnfjörð Bjarmason
Message 8 of 16 in “reftable: avoid undefined behaviour breaking t0032”
  1. reftable: avoid undefined behaviour breaking t0032Carlo Marcelo Arenas Belón, Apr 15, 2022
  2. Junio C HamanoApr 15, 2022
  3. reftable: avoid undefined behaviour breaking t0032Carlo Marcelo Arenas Belón, Apr 15, 2022
  4. 0/2 reftable: remove poor man's SANITIZE=address, fix a memset() bugÆvar Arnfjörð Bjarmason, Apr 15, 2022
  5. 1/2 reftable: remove the "return_block" abstractionÆvar Arnfjörð Bjarmason, Apr 15, 2022
  6. René ScharfeApr 15, 2022
  7. Han-Wen NienhuysApr 25, 2022
  8. Junio C HamanoApr 25, 2022
  9. 2/2 reftable: don't memset() a NULL from failed malloc()Ævar Arnfjörð Bjarmason, Apr 15, 2022
  10. René ScharfeApr 15, 2022
  11. Ævar Arnfjörð BjarmasonApr 15, 2022
  12. Phillip WoodApr 15, 2022
  13. Ævar Arnfjörð BjarmasonApr 15, 2022
  14. Junio C HamanoApr 15, 2022
  15. Han-Wen NienhuysApr 25, 2022
  16. Han-Wen NienhuysApr 25, 2022

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.