Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * Copyright (C) 2017 Red Hat. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * This file is released under the GPL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include "dm-cache-background-tracker.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) /*----------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #define DM_MSG_PREFIX "dm-background-tracker"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) struct bt_work {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 	struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 	struct rb_node node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 	struct policy_work work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) struct background_tracker {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	unsigned max_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	atomic_t pending_promotes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	atomic_t pending_writebacks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	atomic_t pending_demotes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	struct list_head issued;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	struct list_head queued;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	struct rb_root pending;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	struct kmem_cache *work_cache;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) struct background_tracker *btracker_create(unsigned max_work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	struct background_tracker *b = kmalloc(sizeof(*b), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	if (!b) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 		DMERR("couldn't create background_tracker");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	b->max_work = max_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	atomic_set(&b->pending_promotes, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	atomic_set(&b->pending_writebacks, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	atomic_set(&b->pending_demotes, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	INIT_LIST_HEAD(&b->issued);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	INIT_LIST_HEAD(&b->queued);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	b->pending = RB_ROOT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	b->work_cache = KMEM_CACHE(bt_work, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	if (!b->work_cache) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		DMERR("couldn't create mempool for background work items");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 		kfree(b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		b = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	return b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) EXPORT_SYMBOL_GPL(btracker_create);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) void btracker_destroy(struct background_tracker *b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	kmem_cache_destroy(b->work_cache);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	kfree(b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) EXPORT_SYMBOL_GPL(btracker_destroy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) static int cmp_oblock(dm_oblock_t lhs, dm_oblock_t rhs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	if (from_oblock(lhs) < from_oblock(rhs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	if (from_oblock(rhs) < from_oblock(lhs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) static bool __insert_pending(struct background_tracker *b,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 			     struct bt_work *nw)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	int cmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	struct bt_work *w;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	struct rb_node **new = &b->pending.rb_node, *parent = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	while (*new) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		w = container_of(*new, struct bt_work, node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		parent = *new;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		cmp = cmp_oblock(w->work.oblock, nw->work.oblock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		if (cmp < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 			new = &((*new)->rb_left);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		else if (cmp > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 			new = &((*new)->rb_right);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 			/* already present */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 			return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	rb_link_node(&nw->node, parent, new);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	rb_insert_color(&nw->node, &b->pending);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) static struct bt_work *__find_pending(struct background_tracker *b,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 				      dm_oblock_t oblock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	int cmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	struct bt_work *w;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	struct rb_node **new = &b->pending.rb_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	while (*new) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		w = container_of(*new, struct bt_work, node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		cmp = cmp_oblock(w->work.oblock, oblock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		if (cmp < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 			new = &((*new)->rb_left);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		else if (cmp > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 			new = &((*new)->rb_right);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	return *new ? w : NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) static void update_stats(struct background_tracker *b, struct policy_work *w, int delta)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	switch (w->op) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	case POLICY_PROMOTE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		atomic_add(delta, &b->pending_promotes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	case POLICY_DEMOTE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		atomic_add(delta, &b->pending_demotes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	case POLICY_WRITEBACK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		atomic_add(delta, &b->pending_writebacks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) unsigned btracker_nr_writebacks_queued(struct background_tracker *b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	return atomic_read(&b->pending_writebacks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) EXPORT_SYMBOL_GPL(btracker_nr_writebacks_queued);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) unsigned btracker_nr_demotions_queued(struct background_tracker *b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	return atomic_read(&b->pending_demotes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) EXPORT_SYMBOL_GPL(btracker_nr_demotions_queued);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) static bool max_work_reached(struct background_tracker *b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	return atomic_read(&b->pending_promotes) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		atomic_read(&b->pending_writebacks) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		atomic_read(&b->pending_demotes) >= b->max_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) static struct bt_work *alloc_work(struct background_tracker *b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	if (max_work_reached(b))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	return kmem_cache_alloc(b->work_cache, GFP_NOWAIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) int btracker_queue(struct background_tracker *b,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		   struct policy_work *work,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		   struct policy_work **pwork)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	struct bt_work *w;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	if (pwork)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		*pwork = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	w = alloc_work(b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	if (!w)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	memcpy(&w->work, work, sizeof(*work));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	if (!__insert_pending(b, w)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		 * There was a race, we'll just ignore this second
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		 * bit of work for the same oblock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		kmem_cache_free(b->work_cache, w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	if (pwork) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		*pwork = &w->work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		list_add(&w->list, &b->issued);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		list_add(&w->list, &b->queued);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	update_stats(b, &w->work, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) EXPORT_SYMBOL_GPL(btracker_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)  * Returns -ENODATA if there's no work.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) int btracker_issue(struct background_tracker *b, struct policy_work **work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	struct bt_work *w;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	if (list_empty(&b->queued))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		return -ENODATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	w = list_first_entry(&b->queued, struct bt_work, list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	list_move(&w->list, &b->issued);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	*work = &w->work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) EXPORT_SYMBOL_GPL(btracker_issue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) void btracker_complete(struct background_tracker *b,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		       struct policy_work *op)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	struct bt_work *w = container_of(op, struct bt_work, work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	update_stats(b, &w->work, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	rb_erase(&w->node, &b->pending);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	list_del(&w->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	kmem_cache_free(b->work_cache, w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) EXPORT_SYMBOL_GPL(btracker_complete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) bool btracker_promotion_already_present(struct background_tracker *b,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 					dm_oblock_t oblock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	return __find_pending(b, oblock) != NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) EXPORT_SYMBOL_GPL(btracker_promotion_already_present);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) /*----------------------------------------------------------------*/