[Devel] [PATCH RHEL8 COMMIT] ploop: Care about timeout on discard

Konstantin Khorenko khorenko at virtuozzo.com
Tue Mar 10 18:44:59 MSK 2020


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 at virtuozzo.com>
Date:   Tue Mar 10 18:44:59 2020 +0300

    ploop: Care about timeout on discard
    
    Signed-off-by: Kirill Tkhai <ktkhai at 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(-)

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;


More information about the Devel mailing list