]> git.proxmox.com Git - pve-storage.git/commit
remove lock from is_base_and_used check
authorFabian Ebner <f.ebner@proxmox.com>
Fri, 15 Jan 2021 10:58:05 +0000 (11:58 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 6 Feb 2021 13:47:40 +0000 (14:47 +0100)
commit50853be2c5e3b23ae2453910e038dd220f92b9d0
tree6bca532f8ec63900b9747e185a9542d5614b2430
parent2949c537d9fc152723a22c0880108056757388fe
remove lock from is_base_and_used check

and squash the __no_lock-variant into it.

This lock is not broad enough, because for a caller that plans to do or not do
some storage operation based on the result of the check, the following could
happen:
1. volume_is_base_and_used is called and the result is used to enter a branch
2. situation on the storage changes in the meantime
3. the branch chosen in 1. might not be the one that should be taken anymore

This means that callers are responsible for locking, and luckily the existing
callers do use their own locks already:
1. vdisk_free used the __no_lock-variant with a broader lock also covering
   the free operation.
2. vdisk_clone is not a caller, but is relevant and it does lock the storage
2. the calls during VM migration and VM destruction happen in the context of a
   locked VM config. Because the clone operation also locks the VM config, it
   cannot happen that a linked clone is created while the template VM is
   migrated away or destroyed or vice versa. And even if that were the case,
   the base disk would not be freed, because of what vdisk_free/vdisk_clone do.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
PVE/Storage.pm