[pbs-devel] [PATCH proxmox-backup 12/17] datastore: get per-chunk file lock for chunk rename on s3 backend
Christian Ebner
c.ebner at proxmox.com
Tue Nov 4 09:33:13 CET 2025
On 11/3/25 3:51 PM, Fabian Grünbichler wrote:
> On November 3, 2025 12:31 pm, Christian Ebner wrote:
>> To guarantee exclusive access during s3 object store and cache
>> operations, acquire the per-chunk file before renaming a chunk when
>> the datastore is backed by s3.
>>
>> This does not yet cover locking for the GC and chunk insert, part
>> of subsequent changes.
>>
>> Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
>> ---
>> pbs-datastore/src/datastore.rs | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
>> index e7ec87a7f..e65f3a60c 100644
>> --- a/pbs-datastore/src/datastore.rs
>> +++ b/pbs-datastore/src/datastore.rs
>> @@ -2586,6 +2586,7 @@ impl DataStore {
>> let (path, digest_str) = self.chunk_path(digest);
>>
>> let _lock = self.inner.chunk_store.mutex().lock().unwrap();
>> + let _chunk_guard = self.lock_chunk_for_backend(digest)?;
>
> lock inversion?
>
> when inserting into S3, the chunk lock is obtained first, and then the
> mutex is obtained for all insertions in chunk_store.insert_chunk while
> the chunk lock is held.. while we do have a long timeout here, that
> would still be quite bad..
Yes, switched the locking order around here, so now the per-chunk file
lock is obtained first.
More information about the pbs-devel
mailing list