[Devel] [PATCH RHEL7 COMMIT] ploop: Add trim_extent_mappings_tail() helper

Konstantin Khorenko khorenko at virtuozzo.com
Wed Mar 6 14:22:48 MSK 2019


The commit is pushed to "branch-rh7-3.10.0-957.1.3.vz7.93.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.1.3.vz7.83.17
------>
commit 038857c9967edfaad747d616ccd0afbb65f3bf7f
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Wed Mar 6 14:22:46 2019 +0300

    ploop: Add trim_extent_mappings_tail() helper
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    
    =====================
    Patchset description:
    
    ploop: Add online discard support for dio engine
    
    The first part of patchset is preparations to make code
    a bit readable.
    
    The second part adds online discard support for dio engine.
    DIO engine tracks entents, so discard code will use that
    for its needs.
    
    https://pmc.acronis.com/browse/VSTOR-19972
    
    Kirill Tkhai (12):
          ploop: introduce dio_may_fallocate() helper
          ploop: Export whole_block()
          ploop: Add cluster_size_in_bytes() helper
          ploop: Add cluster_size_in_sec() helper
          ploop: Add local variable into dio_submit()
          ploop: Add cluster_log local variable
          ploop: Add trim_extent_mappings_tail() helper
          ploop: Introduce local variable in ploop_start()
          ploop: Never merge discard requests
          ploop: Set up discard limits
          ploop: Introduce ploop_can_issue_discard() helper
          ploop: Online discard support for dio engine
---
 drivers/block/ploop/io_direct.c     |  5 +++--
 drivers/block/ploop/io_direct_map.c |  6 +++---
 drivers/block/ploop/io_direct_map.h | 13 +++++++++++--
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/drivers/block/ploop/io_direct.c b/drivers/block/ploop/io_direct.c
index 3e207a7b9ff5..b0d7095864fc 100644
--- a/drivers/block/ploop/io_direct.c
+++ b/drivers/block/ploop/io_direct.c
@@ -1725,8 +1725,9 @@ static int dio_truncate(struct ploop_io * io, struct file * file,
 
 	mutex_lock(&io->files.inode->i_mutex);
 	if (io->files.em_tree)
-		trim_extent_mappings(io->plo, io->files.em_tree,
-				     newattrs.ia_size>>9);
+		trim_extent_mappings_tail(io->plo, io->files.em_tree,
+					  newattrs.ia_size>>9);
+
 	io->files.inode->i_flags &= ~S_SWAPFILE;
 	err = notify_change(F_DENTRY(file), &newattrs, NULL);
 	io->files.inode->i_flags |= S_SWAPFILE;
diff --git a/drivers/block/ploop/io_direct_map.c b/drivers/block/ploop/io_direct_map.c
index f7784aa32cfa..9afd0610e708 100644
--- a/drivers/block/ploop/io_direct_map.c
+++ b/drivers/block/ploop/io_direct_map.c
@@ -751,13 +751,13 @@ static int drop_extent_map(struct extent_map_tree *tree)
 	return 0;
 }
 
-void trim_extent_mappings(struct ploop_device *plo,
-			  struct extent_map_tree *tree, sector_t start)
+void trim_extent_mappings(struct ploop_device *plo, struct extent_map_tree *tree,
+			  sector_t start, sector_t len)
 {
 	struct extent_map *em;
 
 	spin_lock_irq(&plo->lock);
-	while ((em = lookup_extent_mapping(tree, start, ((sector_t)(-1ULL)) - start))) {
+	while ((em = lookup_extent_mapping(tree, start, len)) != NULL) {
 		remove_extent_mapping(tree, em);
 		WARN_ON(atomic_read(&em->refs) != 2);
 		/* once for us */
diff --git a/drivers/block/ploop/io_direct_map.h b/drivers/block/ploop/io_direct_map.h
index d043d87e22f4..b48a06857567 100644
--- a/drivers/block/ploop/io_direct_map.h
+++ b/drivers/block/ploop/io_direct_map.h
@@ -48,8 +48,8 @@ struct extent_map *extent_lookup(struct extent_map_tree *tree,
 				 sector_t start);
 void ploop_extent_put(struct extent_map *em);
 
-void trim_extent_mappings(struct ploop_device *plo,
-			  struct extent_map_tree *tree, sector_t start);
+void trim_extent_mappings(struct ploop_device *plo, struct extent_map_tree *tree,
+			  sector_t start, sector_t len);
 
 int ploop_dio_close(struct ploop_io * io, int rdonly);
 struct extent_map_tree * ploop_dio_open(struct ploop_io * io, int rdonly);
@@ -59,4 +59,13 @@ int ploop_dio_upgrade(struct ploop_io * io);
 int __init ploop_extent_map_init(void);
 void ploop_extent_map_exit(void);
 
+static inline void trim_extent_mappings_tail(struct ploop_device *plo,
+					     struct extent_map_tree *tree,
+					     sector_t start)
+{
+	sector_t len = ((sector_t)(-1ULL)) - start;
+
+	trim_extent_mappings(plo, tree, start, len);
+}
+
 #endif



More information about the Devel mailing list