On 7/16/25 04:51, Pavel Tikhomirov wrote:


On 7/15/25 22:20, Andrey Zhadchenko wrote:
We do not increase inflight number when we chain pios, so we should
decrease inflight only after all chained pios are also completed,
e.g. pio->remaining is zero, and file is flushed if needed

I see that ploop_inc_nr_inflight and ploop_dec_nr_inflight are designed the way that only if ploop_inc_nr_inflight really happened on pio, then ploop_dec_nr_inflight on it will decrement the inflight reference.

E.g. chained splited pios should just have pio->ref_index == PLOOP_REF_INDEX_INVALID, if there was no ploop_inc_nr_inflight on them, and on "dec" nothing will happen.

So I'm not sure if this patch is really needed.

I guess I couldn't convey the problem.
Yes, split pios have PLOOP_REF_INDEX_INVALID and they do not increment inflight number. The problem is that all of them are part of a single request. Logically inflight counter represents in-flight request counter (as we also do not increase it for metadata pios or cow pios). So we should decrease it only after all pios within a request are completed. The consequences for this is that even when we "stopped submitting" pios and wait for them to finish, we do not count neither split pios nor cow pios. So the problem is that after ploop_suspend_submitting_pios(), which explicitly waits inflight counter to decrease to zero, we actually have regular running pios. And they can also generate new metadata writebacks. That's how I foung it: someone initiated a new metadata writeback even after ploop_suspend_submitting_pios() completed.



https://virtuozzo.atlassian.net/browse/VSTOR-108540
Signed-off-by: Andrey Zhadchenko <andrey.zhadche...@virtuozzo.com>
---
  drivers/md/dm-ploop-map.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 7604b3c8d644..9f2e55df2904 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -214,6 +214,8 @@ static void ploop_prq_endio(struct pio *pio, void *prq_ptr,
      dm_complete_request(rq, bi_status);
  }
+static void ploop_dec_nr_inflight(struct ploop *ploop, struct pio *pio);
+
  static void ploop_wrkr_pio_endio(struct pio *pio)
  {
      ploop_endio_t endio_cb = pio->endio_cb;
@@ -223,6 +225,8 @@ static void ploop_wrkr_pio_endio(struct pio *pio)
      file = ploop_top_delta(pio->ploop)->file;
      vfs_fsync(file, 1);
+
+    ploop_dec_nr_inflight(pio->ploop, pio);
      endio_cb(pio, endio_cb_data, pio->bi_status);
      if (free_on_endio) {
          ploop_free_pio(pio->ploop, pio);
@@ -245,6 +249,7 @@ static void ploop_do_pio_endio(struct pio *pio)
          return;
      }
+    ploop_dec_nr_inflight(pio->ploop, pio);
      endio_cb(pio, endio_cb_data, pio->bi_status);
      if (free_on_endio)
@@ -2695,7 +2700,6 @@ static void ploop_handle_cleanup(struct ploop *ploop, struct pio *pio)
          ploop_discard_index_pio_end(ploop, pio);
      ploop_unlink_completed_pio(ploop, pio);
-    ploop_dec_nr_inflight(ploop, pio);
  }
  /*


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to