The further architecture of discard for ploop1 format
looks for me as following.

blkdev_issue_discard() splits big region into requests
of one block size ((preq->req_size == 1<<plo->cluster_log).
Then requests each other completes in a separate, so we
continue existing data ---> index_writeback scheme.
Another approach, when we try to merge writing of indexes,
which are related to one index page, does not look for me
good, since all the existing code was never written in
an assumption, that a request may iterate on different
index writing, and this will introduce more corner cases,
when we already have in ploop.

For raw format this won't introduce any changes in case
of fstrim, since fstrim sends a request of maximum free
space it sees at a moment. This will touch only online
discard option for ext4, when freed block is not big enough,
but it still will be discardable via fstrim.

Signed-off-by: Kirill Tkhai <[email protected]>
---
 drivers/block/ploop/dev.c   |    8 +++-----
 include/linux/ploop/ploop.h |    2 +-
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 060aa8bcdfde..9ac436201b1b 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -288,9 +288,7 @@ static void preq_set_sync_bit(struct ploop_request * preq)
 
 static struct rb_root *req_entry_tree(struct ploop_device *plo, unsigned rw)
 {
-       if (rw & REQ_DISCARD)
-               return plo->entry_tree + 2;
-       else if (rw & REQ_WRITE)
+       if (rw & REQ_WRITE)
                return plo->entry_tree + 1;
        return plo->entry_tree + 0;
 }
@@ -597,7 +595,7 @@ ploop_bio_queue(struct ploop_device * plo, struct bio * bio,
                plo->bio_qlen--;
        ploop_entry_add(plo, preq);
 
-       if (bio->bi_size && !(preq->state & (1 << PLOOP_REQ_DISCARD)))
+       if (bio->bi_size && !(bio->bi_rw & REQ_DISCARD))
                insert_entry_tree(plo, preq, drop_list);
 
        trace_bio_queue(preq);
@@ -5325,7 +5323,7 @@ static struct ploop_device *__ploop_dev_alloc(int index)
        plo->freeze_timer.function = freeze_timeout;
        plo->freeze_timer.data = (unsigned long)plo;
        INIT_LIST_HEAD(&plo->entry_queue);
-       plo->entry_tree[0] = plo->entry_tree[1] = plo->entry_tree[2] = RB_ROOT;
+       plo->entry_tree[0] = plo->entry_tree[1] = RB_ROOT;
        plo->lockout_tree = RB_ROOT;
        plo->lockout_pb_tree = RB_ROOT;
        INIT_LIST_HEAD(&plo->ready_queue);
diff --git a/include/linux/ploop/ploop.h b/include/linux/ploop/ploop.h
index 58154219d7cb..71a55573bdf6 100644
--- a/include/linux/ploop/ploop.h
+++ b/include/linux/ploop/ploop.h
@@ -382,7 +382,7 @@ struct ploop_device
        int                     bio_qlen;
        int                     bio_total;
 
-       struct rb_root          entry_tree[3];
+       struct rb_root          entry_tree[2];
 
        struct list_head        ready_queue;
 

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to