]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
mgr/volumes: Fix a race during clone cancel 42371/head
authorKotresh HR <khiremat@redhat.com>
Fri, 16 Jul 2021 10:28:37 +0000 (15:58 +0530)
committerKotresh HR <khiremat@redhat.com>
Fri, 30 Jul 2021 07:44:35 +0000 (13:14 +0530)
commite1ccf367dff0b9d57bd5c50477cfa60c76c64762
tree449b8672ed0e7fb6533910c4258cba1dcd4f98bc
parent103c7bdc70ca5316dd9b6dbf67ff0a19e99dc9d6
mgr/volumes: Fix a race during clone cancel

Issue:
The race is that the cancelled clone can still go ahead and sync the data to cloned subvolume.

Here is the sequence how this can happen.
1. Subvolume clone is created and it's in PENDING state (it's the initial state for a clone)
2. The clone job is picked up by the cloner thread, started the state machine (i.e.start_clone_sm)
   and queried the clone state, which is PENDING. So this has local copy of the state at this point.
3. The 'clone cancel' is called which just removes the tracker from index as the state is still PENDING.
   This moves the clone state from PENDING to CANCEL.
4. The cloner thread proceeds further from PENDING (local copy of the state) to IN-PROGRESS.

Fix:
Along with checking for PENDING state, also check whether the job is picked by thread with in the
lock. This guarantees that none of the cloner threads has picked it up for processing and plain
removal of index is sufficient.

Fixes: https://tracker.ceph.com/issues/51805
Signed-off-by: Kotresh HR <khiremat@redhat.com>
src/pybind/mgr/volumes/fs/async_cloner.py
src/pybind/mgr/volumes/fs/async_job.py