[RHEL8,COMMIT] ploop: Care about timeout on discard

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

Details

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

Commit Message

Konstantin Khorenko March 10, 2020, 3:44 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 444c9442255a90f88f72c156c2c8a0d06648bafc
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Tue Mar 10 18:44:59 2020 +0300

    ploop: Care about timeout on discard
    
    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-map.c    | 11 ++++++++++-
 drivers/md/dm-ploop-target.c |  1 +
 2 files changed, 11 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index d7cc5f078e14..07659fdf88f5 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -418,8 +418,10 @@  static void handle_discard_bio(struct ploop *ploop, struct bio *bio,
 	struct dm_ploop_endio_hook *h = bio_to_endio_hook(bio);
 	struct dm_ploop_endio_hook *inflight_h;
 	unsigned long flags;
+	int ret;
 
 	if (!cluster_is_in_top_delta(ploop, cluster) || ploop->nr_deltas) {
+enotsupp:
 		bio->bi_status = BLK_STS_NOTSUPP;
 		bio_endio(bio);
 		return;
@@ -437,7 +439,14 @@  static void handle_discard_bio(struct ploop *ploop, struct bio *bio,
 		 */
 		ploop->force_link_inflight_bios = true;
 		force_defer_bio_count_inc(ploop);
-		ploop_inflight_bios_ref_switch(ploop, false);
+		ret = ploop_inflight_bios_ref_switch(ploop, true);
+		if (ret) {
+			pr_err_ratelimited("ploop: discard ignored by err=%d\n",
+					ret);
+			ploop->force_link_inflight_bios = false;
+			force_defer_bio_count_dec(ploop);
+			goto enotsupp;
+		}
 	}
 
 	spin_lock_irqsave(&ploop->deferred_lock, flags);
diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
index bdeee2334499..546056e7e6d6 100644
--- a/drivers/md/dm-ploop-target.c
+++ b/drivers/md/dm-ploop-target.c
@@ -126,6 +126,7 @@  static int ploop_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 	atomic_set(&ploop->nr_discard_bios, 0);
 
 	INIT_WORK(&ploop->worker, do_ploop_work);
+	init_completion(&ploop->inflight_bios_ref_comp);
 
 	for (i = 0; i < 2; i++) {
 		release = i ? inflight_bios_ref_exit1 : inflight_bios_ref_exit0;