[Devel] [PATCH hci-8.1 v5 6/7] drivers/md/push_backup: do not re-arm deadline timer in push_backup_write()

Andrey Zhadchenko andrey.zhadchenko at virtuozzo.com
Tue Nov 3 15:38:01 MSK 2026


pb_timer_func() checks pb->deadline_jiffies every time it fires and
re-arms itself under pb->lock while requests are delayed, and
postpone_if_required_for_backup() arms it under pb->lock when the first
request is delayed. So the timer is always pending while writes are
delayed and we don't need to re-arm it after updating the field.

This call is also not done under pb->lock. Today it is harmless because
write and stop are serialized by pb->ctl_rwsem, but it would re-arm the
timer behind timer_delete_sync() in push_backup_stop() once the write
path is reachable without the rwsem (next patch).

https://virtuozzo.atlassian.net/browse/VSTOR-152912
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
Reviewed-by: Alexander Ivanov <alexander.ivanov at virtuozzo.com>
---
v2: no changes
v3: no changes
v4: commit message typo
v5: moved after "arm deadline timer under pb->lock", so no bisect
    point re-opens the race; dropped the "only place" claim

 drivers/md/dm-push-backup.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/md/dm-push-backup.c b/drivers/md/dm-push-backup.c
index f0de26add11c2..52ba80b703ff1 100644
--- a/drivers/md/dm-push-backup.c
+++ b/drivers/md/dm-push-backup.c
@@ -463,8 +463,8 @@ static int push_backup_write(struct push_backup *pb,
 			     unsigned int clu, unsigned int nr)
 {
 	u64 i, key, nr_clus = pb->nr_clus;
-	bool finished, has_more = false;
 	LIST_HEAD(pbio_list);
+	bool finished;
 	struct pb_bio *pbio;
 
 	if (!pb)
@@ -515,8 +515,7 @@ static int push_backup_write(struct push_backup *pb,
 		}
 	}
 
-	has_more = (pb->nr_delayed != 0);
-	if (has_more)
+	if (pb->nr_delayed)
 		pb->deadline_jiffies = get_jiffies_64() + pb->timeout_in_jiffies;
 	else
 		pb->deadline_jiffies = S64_MAX;
@@ -525,11 +524,8 @@ static int push_backup_write(struct push_backup *pb,
 	if (finished)
 		wake_up_interruptible(&pb->waitq);
 
-	if (!list_empty(&pbio_list)) {
+	if (!list_empty(&pbio_list))
 		resubmit_pbios(pb, &pbio_list);
-		if (has_more)
-			mod_timer(&pb->deadline_timer, jiffies + pb->timeout_in_jiffies + 1);
-	}
 
 	return 0;
 }
-- 
2.43.5



More information about the Devel mailing list