[rh8,7/7] ploop: Care about timeout on process_update_delta_index()

Submitted by Kirill Tkhai on March 10, 2020, 12:16 p.m.

Details

Message ID 158384260656.212417.7870094938734753759.stgit@localhost.localdomain
State New
Series "ploop: Make service operations care about timeout"
Headers show

Commit Message

Kirill Tkhai March 10, 2020, 12:16 p.m.
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/md/dm-ploop-cmd.c |   16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index cf4795f4cda1..30fea812b9c0 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -880,7 +880,12 @@  static void process_update_delta_index(struct ploop *ploop,
 	const char *map = cmd->update_delta_index.map;
 	u8 level = cmd->update_delta_index.level;
 	unsigned int cluster, dst_cluster, n;
-	int ret = -EINVAL;
+	int ret;
+
+	force_defer_bio_count_inc(ploop);
+	ret = ploop_inflight_bios_ref_switch(ploop, true);
+	if (ret)
+		goto out;
 
 	write_lock_irq(&ploop->bat_rwlock);
 	/* Check all */
@@ -891,8 +896,10 @@  static void process_update_delta_index(struct ploop *ploop,
 			break;
 		map += n;
 	}
-	if (map[0] != '\0')
+	if (map[0] != '\0') {
+		ret = -EINVAL;
 		goto unlock;
+	}
 	/* Commit all */
 	map = cmd->update_delta_index.map;
 	while (sscanf(map, "%u:%u;%n", &cluster, &dst_cluster, &n) == 2) {
@@ -903,9 +910,8 @@  static void process_update_delta_index(struct ploop *ploop,
 	ret = 0;
 unlock:
 	write_unlock_irq(&ploop->bat_rwlock);
-	if (!ret)
-		ploop_inflight_bios_ref_switch(ploop, false);
-
+out:
+	force_defer_bio_count_dec(ploop);
 	cmd->retval = ret;
 	complete(&cmd->comp); /* Last touch of cmd memory */
 }