[pbs-devel] [PATCH pxar] encoder: flush after writing last entry

Wolfgang Bumiller w.bumiller at proxmox.com
Tue Mar 30 09:18:29 CEST 2021


> On 03/30/2021 9:10 AM Dietmar Maurer <dietmar at proxmox.com> wrote:
> 
>  
> > After an off-list talk with Dominik we concluded that keeping it for `Owned`
> > writers is the safer approach for the simple reason that in *async* code (eg.
> > tokio's async BufWriter equivalent) you *do* need to flush buffered writers.
> > 
> > This is probably because there's no `AsyncDrop` and there's no guarantee that
> > the future's `Drop` handler is called in a place where it is safe to call
> > tokio's `block_in_place` (after all it panics when it is outside a tokio RT
> > thread, *including* being inside a `runtime.block_on()` called from outside
> > a tokio RT thread).
> > 
> > So yeah, let's not revert this, but limit it to `EncoderOutput::Owned`.
> 
> But Flushing at every sub-dir makes no real sense. You only need
> to flush once when you are finished writing the pxar (for the top level dir)?

Yes, this is implicitly the case then because nested directories borrow the writer
and therefor always use `EncoderOutput::Borrowed`. Only the top level has the
`Owned` entry. (If this ever changes we can just track this with a boolean or something)





More information about the pbs-devel mailing list