[Devel] [PATCH rh7 1/4] ploop: fix fsync_reqs accounting

Maxim Patlasov mpatlasov at virtuozzo.com
Mon Jul 11 21:57:40 PDT 2016


io->fsync_qlen stands for the number of ploop requests waiting for processing
by io fsync thread.

The fix is obvious: each time we add preq to fsync thread queue, we have to
increment fsync_reqs; each time we delete it from the queue, we have to
decrement it.

The fix should not affect anything because currently nobody cares about the
value of io->fsync_qlen. The patch is useful because we expose the value
as /sys/block/ploopN/pstate/fsync_reqs.

Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
---
 drivers/block/ploop/dev.c       |    1 +
 drivers/block/ploop/io_direct.c |    3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 40768b6..9992ae5 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -2055,6 +2055,7 @@ ploop_entry_request(struct ploop_request * preq)
 		    !test_bit(PLOOP_REQ_FSYNC_DONE, &preq->state)) {
 			spin_lock_irq(&plo->lock);
 			list_add_tail(&preq->list, &top_io->fsync_queue);
+			top_io->fsync_qlen++;
 			if (waitqueue_active(&top_io->fsync_waitq))
 				wake_up_interruptible(&top_io->fsync_waitq);
 			spin_unlock_irq(&plo->lock);
diff --git a/drivers/block/ploop/io_direct.c b/drivers/block/ploop/io_direct.c
index 0a5fb15..fb1ddea 100644
--- a/drivers/block/ploop/io_direct.c
+++ b/drivers/block/ploop/io_direct.c
@@ -477,9 +477,10 @@ try_again:
 		ploop_acc_flush_skip_locked(plo, preq->req_rw);
 		preq->iblock = iblk;
 		list_add_tail(&preq->list, &io->fsync_queue);
+		io->fsync_qlen++;
 		plo->st.bio_syncwait++;
 		if ((test_bit(PLOOP_REQ_SYNC, &preq->state) ||
-		     ++io->fsync_qlen >= plo->tune.fsync_max) &&
+		     io->fsync_qlen >= plo->tune.fsync_max) &&
 		    waitqueue_active(&io->fsync_waitq))
 			wake_up_interruptible(&io->fsync_waitq);
 		else if (!timer_pending(&io->fsync_timer))



More information about the Devel mailing list