[RHEL8,COMMIT] ploop: Care about timeout on process_merge_latest_snapshot_cmd()

Submitted by Konstantin Khorenko on March 10, 2020, 3:45 p.m.

Details

Message ID 202003101545.02AFj0mv025046@finist_co8.work.ct
State New
Series "ploop: Make service operations care about timeout"
Headers show

Commit Message

Konstantin Khorenko March 10, 2020, 3:45 p.m.
The commit is pushed to "branch-rh8-4.18.0-80.1.2.vz8.3.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-80.1.2.vz8.3.2
------>
commit d7d5dd9d5e2c6acba8f4b798665af9a591d96343
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Tue Mar 10 18:45:00 2020 +0300

    ploop: Care about timeout on process_merge_latest_snapshot_cmd()
    
    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
    
    =====================
    Patchset description:
    
    ploop: Make service operations care about timeout
    
    Recently in vz7 we met a situation, when fuse daemon lost a request.
    This patch set makes ploop service operations use timeout to prevent
    a hang in such the situations.
    
    Kirill Tkhai (7):
          ploop: Add timeout to ploop_inflight_bios_ref_switch()
          ploop: Care about timeout on grow and snapshot
          ploop: Care about timeout on tracking start
          ploop: Care about timeout on discard
          ploop: Care about timeout on process_notify_delta_merged()
          ploop: Care about timeout on process_merge_latest_snapshot_cmd()
          ploop: Care about timeout on process_update_delta_index()
---
 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 */
 }