ploop_check_delta_before_flip() locks the live device's md->md_lock and
then a second md_lock from the delta being read into a separate md_root
tree (d_md). They are distinct objects of the same lock class, so lockdep
reports a false "possible recursive locking" deadlock. The two are only
ever taken here and always in this (md, then d_md) order, so annotate the
inner acquire with SINGLE_DEPTH_NESTING.

Fixes: a9cd5e6dc646 ("dm-ploop: Add ploop target driver")
Feature: dm-ploop: ploop target driver
https://virtuozzo.atlassian.net/browse/VSTOR-137234
Signed-off-by: Konstantin Khorenko <[email protected]>
---
 drivers/md/dm-ploop-cmd.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 5fa78e6cff9a..73c5613c82f5 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -1101,7 +1101,13 @@ static int ploop_check_delta_before_flip(struct ploop 
*ploop, struct file *file)
                d_bat_entries = d_md->kmpage;
 
                spin_lock_irq(&md->md_lock); /* read */
-               spin_lock(&d_md->md_lock);
+               /*
+                * md (live device tree) and d_md (delta being read into a
+                * separate md_root tree) are distinct md_page objects of the
+                * same lock class; they are only ever locked here in this
+                * order, so annotate the nesting for lockdep.
+                */
+               spin_lock_nested(&d_md->md_lock, SINGLE_DEPTH_NESTING);
                for (; i <= end; i++) {
                        if (ploop_md_page_cluster_is_in_top_delta(ploop, md, i) 
&&
                            d_bat_entries[i] != BAT_ENTRY_NONE) {
-- 
2.47.1

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to