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

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

Details

Message ID 158384260022.212417.10976017098315855650.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 |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index ad6635b1d14c..cf4795f4cda1 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -727,6 +727,7 @@  static void process_merge_latest_snapshot_cmd(struct ploop *ploop,
 	unsigned int *cluster = &cmd->merge.cluster;
 	unsigned int level, dst_cluster;
 	struct file *file;
+	int ret;
 
 	if (cmd->retval)
 		goto out;
@@ -765,12 +766,17 @@  static void process_merge_latest_snapshot_cmd(struct ploop *ploop,
 
 	if (cmd->retval == 0 && !cmd->merge.do_repeat) {
 		/* Delta merged. Release delta's file */
+		ret = ploop_inflight_bios_ref_switch(ploop, true);
+		if (ret) {
+			cmd->retval = ret;
+			goto complete;
+		}
 		write_lock_irq(&ploop->bat_rwlock);
 		file = ploop->deltas[--ploop->nr_deltas].file;
 		write_unlock_irq(&ploop->bat_rwlock);
-		ploop_inflight_bios_ref_switch(ploop, false);
 		fput(file);
 	}
+complete:
 	complete(&cmd->comp); /* Last touch of cmd memory */
 }