[RHEL8,COMMIT] dm-ploop: Generalize defer_bio() and defer_bio_list()

Submitted by Konstantin Khorenko on Dec. 7, 2020, 5:31 p.m.

Details

Message ID 202012071731.0B7HVdCJ1832273@finist-co8.sw.ru
State New
Series "dm-ploop: Generalize defer_bio() and defer_bio_list()"
Headers show

Commit Message

Konstantin Khorenko Dec. 7, 2020, 5:31 p.m.
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.el8
------>
commit 2251161515d7aa39fc22d0ed2be193c0475a05b6
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Fri Dec 4 19:13:11 2020 +0300

    dm-ploop: Generalize defer_bio() and defer_bio_list()
    
    ..since they do almost the same.
    
    Fixes: 7264d1dd954a ("dm: Interpreter of ploop1 format (ploop driver)")
    
    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/md/dm-ploop-cmd.c |  2 +-
 drivers/md/dm-ploop-map.c | 29 +++++++++++------------------
 drivers/md/dm-ploop.h     |  3 +--
 3 files changed, 13 insertions(+), 21 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 5f2c93579e53..31fa424a88f5 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -1722,7 +1722,7 @@  static int ploop_push_backup_write(struct ploop *ploop, char *uuid,
 	spin_unlock_irq(&ploop->pb_lock);
 
 	if (!bio_list_empty(&bio_list)) {
-		defer_bio_list(ploop, &bio_list);
+		defer_bios(ploop, NULL, &bio_list);
 		if (has_more)
 			mod_timer(&pb->deadline_timer, pb->timeout_in_jiffies + 1);
 	}
diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index fadee7b2f0a6..4b12b5fc082a 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -118,23 +118,16 @@  static int ploop_bio_cluster(struct ploop *ploop, struct bio *bio,
 	return 0;
 }
 
-void defer_bio(struct ploop *ploop, struct bio *bio)
+void defer_bios(struct ploop *ploop, struct bio *bio, struct bio_list *bl)
 {
 	unsigned long flags;
 
 	spin_lock_irqsave(&ploop->deferred_lock, flags);
-	bio_list_add(&ploop->deferred_bios, bio);
-	spin_unlock_irqrestore(&ploop->deferred_lock, flags);
-
-	queue_work(ploop->wq, &ploop->worker);
-}
-
-void defer_bio_list(struct ploop *ploop, struct bio_list *bio_list)
-{
-	unsigned long flags;
+	if (bio)
+		bio_list_add(&ploop->deferred_bios, bio);
+	if (bl)
+		bio_list_merge(&ploop->deferred_bios, bl);
 
-	spin_lock_irqsave(&ploop->deferred_lock, flags);
-	bio_list_merge(&ploop->deferred_bios, bio_list);
 	spin_unlock_irqrestore(&ploop->deferred_lock, flags);
 	queue_work(ploop->wq, &ploop->worker);
 }
@@ -193,7 +186,7 @@  static int ploop_map_discard(struct ploop *ploop, struct bio *bio)
 	}
 
 	if (supported) {
-		defer_bio(ploop, bio);
+		defer_bios(ploop, bio, NULL);
 	} else {
 		bio->bi_status = BLK_STS_NOTSUPP;
 		bio_endio(bio);
@@ -1077,7 +1070,7 @@  static void queue_or_fail(struct ploop *ploop, int err, void *data)
 		bio->bi_status = errno_to_blk_status(err);
 		bio_endio(bio);
 	} else {
-		defer_bio(ploop, bio);
+		defer_bios(ploop, bio, NULL);
 	}
 }
 
@@ -1257,7 +1250,7 @@  static bool locate_new_cluster_and_attach_bio(struct ploop *ploop,
 
 	if (piwb->page_nr != page_nr || piwb->type != PIWB_TYPE_ALLOC) {
 		/* Another BAT page wb is in process */
-		defer_bio(ploop, bio);
+		defer_bios(ploop, bio, NULL);
 		goto out;
 	}
 
@@ -1273,7 +1266,7 @@  static bool locate_new_cluster_and_attach_bio(struct ploop *ploop,
 		 * batch? Delay submitting. Good thing, that cluster allocation
 		 * has already made, and it goes in the batch.
 		 */
-		defer_bio(ploop, bio);
+		defer_bios(ploop, bio, NULL);
 	}
 out:
 	return attached;
@@ -1530,7 +1523,7 @@  void cleanup_backup(struct ploop *ploop)
 	spin_unlock_irq(&ploop->pb_lock);
 
 	if (!bio_list_empty(&bio_list))
-		defer_bio_list(ploop, &bio_list);
+		defer_bios(ploop, NULL, &bio_list);
 
 	del_timer_sync(&pb->deadline_timer);
 }
@@ -1649,7 +1642,7 @@  int ploop_map(struct dm_target *ti, struct bio *bio)
 
 		if (!in_top_delta) {
 			if (op_is_write(bio->bi_opf) || dst_cluster != BAT_ENTRY_NONE) {
-				defer_bio(ploop, bio);
+				defer_bios(ploop, bio, NULL);
 			} else {
 				zero_fill_bio(bio);
 				bio_endio(bio);
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 5e0c88249dcd..dc5362f01e21 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -493,8 +493,7 @@  extern bool try_update_bat_entry(struct ploop *ploop, unsigned int cluster,
 				 u8 level, unsigned int dst_cluster);
 
 extern int ploop_add_delta(struct ploop *ploop, const char *arg);
-extern void defer_bio(struct ploop *ploop, struct bio *bio);
-extern void defer_bio_list(struct ploop *ploop, struct bio_list *bio_list);
+extern void defer_bios(struct ploop *ploop, struct bio *bio, struct bio_list *bio_list);
 extern void do_ploop_work(struct work_struct *ws);
 extern void process_deferred_cmd(struct ploop *ploop,
 			struct ploop_index_wb *piwb);

Comments

Kirill Tkhai Dec. 8, 2020, 8:08 a.m.
On 07.12.2020 20:31, Konstantin Khorenko wrote:
> 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.el8
> ------>
> commit 2251161515d7aa39fc22d0ed2be193c0475a05b6
> Author: Kirill Tkhai <ktkhai@virtuozzo.com>
> Date:   Fri Dec 4 19:13:11 2020 +0300
> 
>     dm-ploop: Generalize defer_bio() and defer_bio_list()
>     
>     ..since they do almost the same.
>     
>     Fixes: 7264d1dd954a ("dm: Interpreter of ploop1 format (ploop driver)")

I don't understand this. "Fixes:" is tag for BUGs.
     
>     Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
> ---
>  drivers/md/dm-ploop-cmd.c |  2 +-
>  drivers/md/dm-ploop-map.c | 29 +++++++++++------------------
>  drivers/md/dm-ploop.h     |  3 +--
>  3 files changed, 13 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
> index 5f2c93579e53..31fa424a88f5 100644
> --- a/drivers/md/dm-ploop-cmd.c
> +++ b/drivers/md/dm-ploop-cmd.c
> @@ -1722,7 +1722,7 @@ static int ploop_push_backup_write(struct ploop *ploop, char *uuid,
>  	spin_unlock_irq(&ploop->pb_lock);
>  
>  	if (!bio_list_empty(&bio_list)) {
> -		defer_bio_list(ploop, &bio_list);
> +		defer_bios(ploop, NULL, &bio_list);
>  		if (has_more)
>  			mod_timer(&pb->deadline_timer, pb->timeout_in_jiffies + 1);
>  	}
> diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
> index fadee7b2f0a6..4b12b5fc082a 100644
> --- a/drivers/md/dm-ploop-map.c
> +++ b/drivers/md/dm-ploop-map.c
> @@ -118,23 +118,16 @@ static int ploop_bio_cluster(struct ploop *ploop, struct bio *bio,
>  	return 0;
>  }
>  
> -void defer_bio(struct ploop *ploop, struct bio *bio)
> +void defer_bios(struct ploop *ploop, struct bio *bio, struct bio_list *bl)
>  {
>  	unsigned long flags;
>  
>  	spin_lock_irqsave(&ploop->deferred_lock, flags);
> -	bio_list_add(&ploop->deferred_bios, bio);
> -	spin_unlock_irqrestore(&ploop->deferred_lock, flags);
> -
> -	queue_work(ploop->wq, &ploop->worker);
> -}
> -
> -void defer_bio_list(struct ploop *ploop, struct bio_list *bio_list)
> -{
> -	unsigned long flags;
> +	if (bio)
> +		bio_list_add(&ploop->deferred_bios, bio);
> +	if (bl)
> +		bio_list_merge(&ploop->deferred_bios, bl);
>  
> -	spin_lock_irqsave(&ploop->deferred_lock, flags);
> -	bio_list_merge(&ploop->deferred_bios, bio_list);
>  	spin_unlock_irqrestore(&ploop->deferred_lock, flags);
>  	queue_work(ploop->wq, &ploop->worker);
>  }
> @@ -193,7 +186,7 @@ static int ploop_map_discard(struct ploop *ploop, struct bio *bio)
>  	}
>  
>  	if (supported) {
> -		defer_bio(ploop, bio);
> +		defer_bios(ploop, bio, NULL);
>  	} else {
>  		bio->bi_status = BLK_STS_NOTSUPP;
>  		bio_endio(bio);
> @@ -1077,7 +1070,7 @@ static void queue_or_fail(struct ploop *ploop, int err, void *data)
>  		bio->bi_status = errno_to_blk_status(err);
>  		bio_endio(bio);
>  	} else {
> -		defer_bio(ploop, bio);
> +		defer_bios(ploop, bio, NULL);
>  	}
>  }
>  
> @@ -1257,7 +1250,7 @@ static bool locate_new_cluster_and_attach_bio(struct ploop *ploop,
>  
>  	if (piwb->page_nr != page_nr || piwb->type != PIWB_TYPE_ALLOC) {
>  		/* Another BAT page wb is in process */
> -		defer_bio(ploop, bio);
> +		defer_bios(ploop, bio, NULL);
>  		goto out;
>  	}
>  
> @@ -1273,7 +1266,7 @@ static bool locate_new_cluster_and_attach_bio(struct ploop *ploop,
>  		 * batch? Delay submitting. Good thing, that cluster allocation
>  		 * has already made, and it goes in the batch.
>  		 */
> -		defer_bio(ploop, bio);
> +		defer_bios(ploop, bio, NULL);
>  	}
>  out:
>  	return attached;
> @@ -1530,7 +1523,7 @@ void cleanup_backup(struct ploop *ploop)
>  	spin_unlock_irq(&ploop->pb_lock);
>  
>  	if (!bio_list_empty(&bio_list))
> -		defer_bio_list(ploop, &bio_list);
> +		defer_bios(ploop, NULL, &bio_list);
>  
>  	del_timer_sync(&pb->deadline_timer);
>  }
> @@ -1649,7 +1642,7 @@ int ploop_map(struct dm_target *ti, struct bio *bio)
>  
>  		if (!in_top_delta) {
>  			if (op_is_write(bio->bi_opf) || dst_cluster != BAT_ENTRY_NONE) {
> -				defer_bio(ploop, bio);
> +				defer_bios(ploop, bio, NULL);
>  			} else {
>  				zero_fill_bio(bio);
>  				bio_endio(bio);
> diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
> index 5e0c88249dcd..dc5362f01e21 100644
> --- a/drivers/md/dm-ploop.h
> +++ b/drivers/md/dm-ploop.h
> @@ -493,8 +493,7 @@ extern bool try_update_bat_entry(struct ploop *ploop, unsigned int cluster,
>  				 u8 level, unsigned int dst_cluster);
>  
>  extern int ploop_add_delta(struct ploop *ploop, const char *arg);
> -extern void defer_bio(struct ploop *ploop, struct bio *bio);
> -extern void defer_bio_list(struct ploop *ploop, struct bio_list *bio_list);
> +extern void defer_bios(struct ploop *ploop, struct bio *bio, struct bio_list *bio_list);
>  extern void do_ploop_work(struct work_struct *ws);
>  extern void process_deferred_cmd(struct ploop *ploop,
>  			struct ploop_index_wb *piwb);
>