[pbs-devel] [PATCH v3 proxmox-backup 1/5] fix #3847: datastore: support writing fidx files of unknown size

Fabian Grünbichler f.gruenbichler at proxmox.com
Mon Jan 19 14:25:43 CET 2026


On January 19, 2026 1:54 pm, Robert Obkircher wrote:
> 
> On 1/16/26 15:28, Fabian Grünbichler wrote:
>> Quoting Robert Obkircher (2026-01-16 13:42:36)
>>> On 1/14/26 14:13, Fabian Grünbichler wrote:
>>>> On January 9, 2026 6:35 pm, Robert Obkircher wrote:
 
 [..]

>>>>> +    pub fn grow_to_size(&mut self, requested_size: usize) -> Result<(), Error> {
>>>>> +        if self.size < requested_size {
>>>>> +            if !self.growable_size {
>>>>> +                bail!("refusing to resize from {} to {requested_size}", self.size);
>>>>> +            }
>>>>> +            let new_len = requested_size.div_ceil(self.chunk_size);
>>>>> +            if new_len * self.chunk_size != requested_size {
>>>>> +                // not a full chunk, so this must be the last one
>>>>> +                self.growable_size = false;
>>>>> +                self.set_index_capacity_or_unmap(new_len)?;
>>>>> +            } else if new_len > self.index_capacity {
>>>>> +                self.set_index_capacity_or_unmap(new_len.next_power_of_two())?;
>>>>> +            };
>>>>> +            assert!(new_len <= self.index_capacity);
>>>>> +            self.index_length = new_len;
>>>>> +            self.size = requested_size;
>>>>> +        }
>>>> should we handle the else part here? i.e., error out if shrinking is
>>>> requested?
>>> The else part is expected to succeed. I considered renaming the method to
>>> something like grow_if_smaller or ensure_capacity to make this clear, but
>>> I'm not quite happy with those names either.
>> we could
>> - call it resize, move the size check to the (only) call site, and allow
>>    shrinking
>> - call it reserve, make it only handle capacity, and move the size update to a
>>    (renamed) check_chunk_alignment
>> - combine grow_to_size and check_chunk_alignment and find a fitting name for
>>    what it does :-P
>> - keep it as is, but find a better name
> 
> Another option would be a single add_chunk(&mut self, offset, size, digest)
> method that does everything, so the badly named resize method can
> simply stay private.

that seems like possibly the nicest solution here..




More information about the pbs-devel mailing list