[Devel,rh7,2/3] ploop: factor out add preq to fsync_queue

Submitted by Maxim Patlasov on July 21, 2016, 2:01 a.m.

Details

Message ID 20160721020128.13387.33553.stgit@maxim-thinkpad
State New
Series "Series without cover letter"
Headers show

Commit Message

Maxim Patlasov July 21, 2016, 2:01 a.m.
Simple re-work. No logic changed. Will be useful for the next patch.

Signed-off-by: Maxim Patlasov <mpatlasov@virtuozzo.com>
---
 drivers/block/ploop/dev.c   |   19 ++++++++++++++-----
 include/linux/ploop/ploop.h |    1 +
 2 files changed, 15 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 3dc94ca..df3eec9 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -2028,6 +2028,19 @@  static inline bool preq_is_special(struct ploop_request * preq)
 			PLOOP_REQ_ZERO_FL);
 }
 
+void ploop_add_req_to_fsync_queue(struct ploop_request * preq)
+{
+	struct ploop_device * plo       = preq->plo;
+	struct ploop_delta  * top_delta = ploop_top_delta(plo);
+	struct ploop_io     * top_io    = &top_delta->io;
+
+	spin_lock_irq(&plo->lock);
+	list_add_tail(&preq->list, &top_io->fsync_queue);
+	if (waitqueue_active(&top_io->fsync_waitq))
+		wake_up_interruptible(&top_io->fsync_waitq);
+	spin_unlock_irq(&plo->lock);
+}
+
 static void
 ploop_entry_request(struct ploop_request * preq)
 {
@@ -2053,11 +2066,7 @@  ploop_entry_request(struct ploop_request * preq)
 		if ((preq->req_rw & REQ_FLUSH) &&
 		    test_bit(PLOOP_IO_FSYNC_DELAYED, &top_io->io_state) &&
 		    !test_bit(PLOOP_REQ_FSYNC_DONE, &preq->state)) {
-			spin_lock_irq(&plo->lock);
-			list_add_tail(&preq->list, &top_io->fsync_queue);
-			if (waitqueue_active(&top_io->fsync_waitq))
-				wake_up_interruptible(&top_io->fsync_waitq);
-			spin_unlock_irq(&plo->lock);
+			ploop_add_req_to_fsync_queue(preq);
 			return;
 		}
 
diff --git a/include/linux/ploop/ploop.h b/include/linux/ploop/ploop.h
index 3d52f28..d8e01b6 100644
--- a/include/linux/ploop/ploop.h
+++ b/include/linux/ploop/ploop.h
@@ -809,6 +809,7 @@  void ploop_index_update(struct ploop_request * preq);
 void ploop_index_wb_complete(struct ploop_request * preq);
 int __init ploop_map_init(void);
 void ploop_map_exit(void);
+void ploop_add_req_to_fsync_queue(struct ploop_request * preq);
 
 
 void ploop_quiesce(struct ploop_device * plo);