[Devel] [PATCH RHEL8 COMMIT] ploop: Use ploop_call_rw_iter() in submit_delta_read()

Konstantin Khorenko khorenko at virtuozzo.com
Thu Jun 17 19:01:04 MSK 2021


The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.44
------>
commit df10286a75ed6dab69f6752b14895349acd20fba
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Thu Jun 17 19:01:04 2021 +0300

    ploop: Use ploop_call_rw_iter() in submit_delta_read()
    
    Remove duplicate code by using ploop_call_rw_iter().
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    
    =====================
    Patchset description:
    
    ploop: Allow to resubmit partially completed request
    
    This allows to continue submitting partially completed requests.
    
    https://jira.sw.ru/browse/PSBM-127225
    
    Kirill Tkhai (18):
          ploop: Simplify ploop_write_cluster_sync()
          ploop: Rename hook->pio, h->pio, ploop_cow::hook->aux_pio
          ploop: Rename force_link_inflight_bios
          ploop: Introduce separate lock for inflight pios
          ploop: Use hlist instead of rbtree
          ploop: Always link submitted pios
          ploop: Unexport ploop_inflight_bios_ref_switch()
          ploop: Refactor submit_pio()
          ploop: Introduce ploop_suspend_submitting_pios
          ploop: Refactor ploop_ctr()
          ploop: Use ploop_call_rw_iter() in submit_delta_read()
          ploop: Generalize submit_rw_mapped()
          ploop: Kill submit_delta_read()
          ploop: Rename submit_rw_mapped()
          ploop: Extract submit_rw_mapped() to separate function
          ploop: Save level before submitting pio
          ploop: Make fsync work be able to run in parallel with main work
          ploop: Introduce resubmitting partially completed pios
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/md/dm-ploop-map.c    | 48 +++-----------------------------------------
 drivers/md/dm-ploop-target.c |  7 +------
 drivers/md/dm-ploop.h        |  7 -------
 3 files changed, 4 insertions(+), 58 deletions(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index c1c1c2a4538d..54eef62658a4 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -999,26 +999,6 @@ static bool ploop_attach_end_action(struct pio *pio, struct ploop_index_wb *piwb
 	return true;
 }
 
-static void ploop_read_aio_do_completion(struct ploop_iocb *piocb)
-{
-	struct pio *pio = piocb->pio;
-
-	if (!atomic_dec_and_test(&piocb->count))
-		return;
-	pio_endio(pio);
-	kmem_cache_free(piocb_cache, piocb);
-}
-
-static void ploop_read_aio_complete(struct kiocb *iocb, long ret, long ret2)
-{
-        struct ploop_iocb *piocb = container_of(iocb, struct ploop_iocb, iocb);
-	struct pio *pio = piocb->pio;
-
-	if (ret != pio->bi_iter.bi_size)
-		pio->bi_status = BLK_STS_IOERR;
-        ploop_read_aio_do_completion(piocb);
-}
-
 static void data_rw_complete(struct pio *pio)
 {
 	bool completed;
@@ -1065,22 +1045,13 @@ void submit_rw_mapped(struct ploop *ploop, u32 dst_clu, struct pio *pio)
 static void submit_delta_read(struct ploop *ploop, unsigned int level,
 			    unsigned int dst_cluster, struct pio *pio)
 {
-	unsigned int flags, offset;
-	struct ploop_iocb *piocb;
 	struct bio_vec *bvec;
 	struct iov_iter iter;
+	unsigned int offset;
 	struct file *file;
 	loff_t pos;
-	int ret;
 
-	piocb = kmem_cache_zalloc(piocb_cache, GFP_NOIO);
-	if (!piocb) {
-		pio->bi_status = BLK_STS_RESOURCE;
-		pio_endio(pio);
-		return;
-	}
-	atomic_set(&piocb->count, 2);
-	piocb->pio = pio;
+	pio->complete = data_rw_complete;
 
 	remap_to_cluster(ploop, pio, dst_cluster);
 
@@ -1093,20 +1064,7 @@ static void submit_delta_read(struct ploop *ploop, unsigned int level,
 	pos = (pio->bi_iter.bi_sector << SECTOR_SHIFT);
 	file = ploop->deltas[level].file;
 
-	piocb->iocb.ki_pos = pos;
-	piocb->iocb.ki_filp = file;
-	piocb->iocb.ki_complete = ploop_read_aio_complete;
-	piocb->iocb.ki_flags = IOCB_DIRECT;
-	piocb->iocb.ki_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0);
-
-	flags = memalloc_noio_save();
-	ret = call_read_iter(file, &piocb->iocb, &iter);
-	memalloc_noio_restore(flags);
-
-	ploop_read_aio_do_completion(piocb);
-
-	if (ret != -EIOCBQUEUED)
-		piocb->iocb.ki_complete(&piocb->iocb, ret, 0);
+	ploop_call_rw_iter(file, pos, READ, &iter, pio);
 }
 
 static void initiate_delta_read(struct ploop *ploop, unsigned int level,
diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
index 71bda7026482..aa6b576b93b1 100644
--- a/drivers/md/dm-ploop-target.c
+++ b/drivers/md/dm-ploop-target.c
@@ -19,7 +19,6 @@ module_param(ignore_signature_disk_in_use, bool, 0444);
 MODULE_PARM_DESC(ignore_signature_disk_in_use,
                 "Does not check for SIGNATURE_DISK_IN_USE");
 
-struct kmem_cache *piocb_cache;
 struct kmem_cache *cow_cache;
 
 static void ploop_aio_do_completion(struct pio *pio)
@@ -430,11 +429,9 @@ static int __init dm_ploop_init(void)
 {
 	int r = -ENOMEM;
 
-	piocb_cache = kmem_cache_create("ploop-iocb", sizeof(struct ploop_iocb),
-					0, 0, NULL);
 	cow_cache = kmem_cache_create("ploop-cow", sizeof(struct ploop_cow),
 				      0, 0, NULL);
-	if (!piocb_cache || !cow_cache)
+	if (!cow_cache)
 		goto err;
 
 	r = dm_register_target(&ploop_target);
@@ -445,7 +442,6 @@ static int __init dm_ploop_init(void)
 
 	return 0;
 err:
-	kmem_cache_destroy(piocb_cache);
 	kmem_cache_destroy(cow_cache);
 	return r;
 }
@@ -454,7 +450,6 @@ static void __exit dm_ploop_exit(void)
 {
 	dm_unregister_target(&ploop_target);
 	kmem_cache_destroy(cow_cache);
-	kmem_cache_destroy(piocb_cache);
 }
 
 module_init(dm_ploop_init);
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index ce9c568779f9..6fc3777e98cd 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -237,12 +237,6 @@ struct pio {
 	void *data;
 };
 
-struct ploop_iocb {
-	struct kiocb iocb;
-	struct pio *pio;
-	atomic_t count;
-};
-
 /* Delta COW private */
 struct ploop_cow {
 	struct ploop *ploop;
@@ -256,7 +250,6 @@ struct ploop_cow {
 };
 
 extern bool ignore_signature_disk_in_use;
-extern struct kmem_cache *piocb_cache;
 extern struct kmem_cache *cow_cache;
 
 #define ploop_for_each_md_page(ploop, md, node)		\


More information about the Devel mailing list