[Devel] [PATCH RHEL8 COMMIT] push_backup: Change retval postpone_if_required_for_backup()

Konstantin Khorenko khorenko at virtuozzo.com
Fri Sep 10 20:16:50 MSK 2021


The commit is pushed to "branch-rh8-4.18.0-305.3.1.vz8.7.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-305.3.1.vz8.7.11
------>
commit 83fc54ea76dfd842c5716e338ed32c857a30ed04
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Fri Sep 10 20:16:49 2021 +0300

    push_backup: Change retval postpone_if_required_for_backup()
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    
    ====================
    push_backup: Make target !immutable.
    
    https://jira.sw.ru/browse/PSBM-127989
    
    Kirill Tkhai (14):
          push_backup: Rename ppb_map
          push_backup: Add unsigned long alignment
          push_backup: Add pending_map
          push_backup: Kill find_node_pbio_range()
          push_backup: Use nr_delayed in postpone_if_required_for_backup()
          push_backup: Introduce hash table
          push_backup: Leave pending pbio in pending queue
          push_backup: Do not split bios by cluster size
          dm: Allow singleton target with devices attached
          dm: Introduce dm_requeue_original_rq()
          push_backup: Make it request based
          push_backup: Change retval postpone_if_required_for_backup()
          push_backup: Change arguments of calc_bio_clusters()
          push_backup: Make the target !immutable
---
 drivers/md/dm-push-backup.c | 32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/drivers/md/dm-push-backup.c b/drivers/md/dm-push-backup.c
index 198fe0e55a32..044b7569654e 100644
--- a/drivers/md/dm-push-backup.c
+++ b/drivers/md/dm-push-backup.c
@@ -102,8 +102,8 @@ static void calc_bio_clusters(struct push_backup *pb, struct request *rq,
 	pbio->end_clu = (off + blk_rq_bytes(rq) - 1) / pb->clu_size;
 }
 
-static bool setup_if_required_for_backup(struct push_backup *pb, struct request *rq,
-					 struct pb_bio *pbio)
+static int setup_if_required_for_backup(struct push_backup *pb, struct request *rq,
+					struct pb_bio *pbio)
 {
 	u64 key;
 
@@ -114,9 +114,9 @@ static bool setup_if_required_for_backup(struct push_backup *pb, struct request
 	if (key != U64_MAX) {
 		pbio->rq = rq;
 		pbio->key_clu = key;
-		return true;
+		return 1;
 	}
-	return false;
+	return 0;
 }
 
 static void update_pending_map(struct push_backup *pb, struct pb_bio *pbio)
@@ -232,22 +232,26 @@ static void pb_timer_func(struct timer_list *timer)
 		queue_work(pb->wq, &pb->worker);
 }
 
-static bool postpone_if_required_for_backup(struct push_backup *pb,
-					    struct request *rq,
-					    struct pb_bio *pbio)
+static int postpone_if_required_for_backup(struct push_backup *pb,
+					   struct request *rq,
+					   struct pb_bio *pbio)
 {
-	bool queue_timer = false, postpone = false;
+	bool queue_timer = false;
 	unsigned long flags;
+	int ret = 0;
 
 	rcu_read_lock(); /* See push_backup_stop() */
 	spin_lock_irqsave(&pb->lock, flags);
-	if (!pb->alive || !setup_if_required_for_backup(pb, rq, pbio))
+	if (!pb->alive)
+		goto unlock;
+	ret = setup_if_required_for_backup(pb, rq, pbio);
+	if (ret <= 0)
 		goto unlock;
 
 	update_pending_map(pb, pbio);
 	link_pending_pbio(pb, pbio);
 
-	postpone = true;
+	ret = 1;
 	pb->nr_delayed += 1;
 	if (pb->nr_delayed == 1) {
 		pb->deadline_jiffies = get_jiffies_64() + pb->timeout_in_jiffies;
@@ -263,7 +267,7 @@ static bool postpone_if_required_for_backup(struct push_backup *pb,
 	if (queue_timer)
 		wake_up_interruptible(&pb->waitq);
 
-	return postpone;
+	return ret;
 }
 
 static inline struct pb_bio *map_info_to_embedded_pbio(union map_info *info)
@@ -281,9 +285,13 @@ static int pb_clone_and_map(struct dm_target *ti, struct request *rq,
 	struct block_device *bdev = pb->origin_dev->bdev;
 	struct request_queue *q;
 	struct request *clone;
+	int ret;
 
 	if (blk_rq_bytes(rq) && op_is_write(req_op(rq))) {
-		if (postpone_if_required_for_backup(pb, rq, pbio))
+		ret = postpone_if_required_for_backup(pb, rq, pbio);
+		if (ret < 0) /* ENOMEM */
+			return DM_MAPIO_REQUEUE;
+		if (ret > 0) /* Postponed */
 			return DM_MAPIO_SUBMITTED;
 	}
 


More information about the Devel mailing list