[Devel] [PATCH vz7 v2] ploop: silence lockdep warning in setting discard_granularity via sysfs

Alexander Atanasov alexander.atanasov at virtuozzo.com
Wed Aug 30 20:08:05 MSK 2023


Lockdep reports circular lock dependency here
&p->lock --> &plo->ctl_mutex --> sb_writers.
this is only triggered by trinity and it did not happen
in real world for the last 10 years. fixing it at this stage is not feasible
since it could break so many things.
So take the safe route and just disable lockdep when updating discard_granularity.

https://jira.vzint.dev/browse/PSBM-149698
Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
---
 drivers/block/ploop/sysfs.c | 2 ++
 1 file changed, 2 insertions(+)

v1->v2: moved lockdep disable in the store_discard_granularity function

diff --git a/drivers/block/ploop/sysfs.c b/drivers/block/ploop/sysfs.c
index c3cc707ec323..f42c3471fa08 100644
--- a/drivers/block/ploop/sysfs.c
+++ b/drivers/block/ploop/sysfs.c
@@ -380,6 +380,7 @@ static int store_discard_granularity(struct ploop_device *plo, u32 val)
 	struct inode *inode;
 	int ret = 0;
 
+	lockdep_off();
 	mutex_lock(&plo->ctl_mutex);
 	if (test_bit(PLOOP_S_RUNNING, &plo->state)) {
 		ret = -EBUSY;
@@ -454,6 +455,7 @@ static int store_discard_granularity(struct ploop_device *plo, u32 val)
 
 unlock:
 	mutex_unlock(&plo->ctl_mutex);
+	lockdep_on();
 	return ret;
 }
 
-- 
2.39.3



More information about the Devel mailing list