summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Thornber <ejt@redhat.com>2023-01-26 13:14:26 +0300
committerMike Snitzer <snitzer@kernel.org>2023-01-30 22:20:04 +0300
commit22c40e134c4c7a828ac09d25a5a8597b1e45c031 (patch)
treea59ac11effdb49436e50558d1384e19ad85abb34
parent95ab80a8a0fef2ce0cc494a306dd283948066ce7 (diff)
downloadlinux-22c40e134c4c7a828ac09d25a5a8597b1e45c031.tar.xz
dm cache: Add some documentation to dm-cache-background-tracker.h
Signed-off-by: Joe Thornber <ejt@redhat.com> Signed-off-by: Mike Snitzer <snitzer@kernel.org>
-rw-r--r--drivers/md/dm-cache-background-tracker.h40
1 files changed, 37 insertions, 3 deletions
diff --git a/drivers/md/dm-cache-background-tracker.h b/drivers/md/dm-cache-background-tracker.h
index 27ab90dbc275..b5056e8275c1 100644
--- a/drivers/md/dm-cache-background-tracker.h
+++ b/drivers/md/dm-cache-background-tracker.h
@@ -12,19 +12,44 @@
/*----------------------------------------------------------------*/
+/*
+ * The cache policy decides what background work should be performed,
+ * such as promotions, demotions and writebacks. The core cache target
+ * is in charge of performing the work, and does so when it sees fit.
+ *
+ * The background_tracker acts as a go between. Keeping track of future
+ * work that the policy has decided upon, and handing (issuing) it to
+ * the core target when requested.
+ *
+ * There is no locking in this, so calls will probably need to be
+ * protected with a spinlock.
+ */
+
struct background_work;
struct background_tracker;
/*
- * FIXME: discuss lack of locking in all methods.
+ * Create a new tracker, it will not be able to queue more than
+ * 'max_work' entries.
*/
struct background_tracker *btracker_create(unsigned max_work);
+
+/*
+ * Destroy the tracker. No issued, but not complete, work should
+ * exist when this is called. It is fine to have queued but unissued
+ * work.
+ */
void btracker_destroy(struct background_tracker *b);
unsigned btracker_nr_writebacks_queued(struct background_tracker *b);
unsigned btracker_nr_demotions_queued(struct background_tracker *b);
/*
+ * Queue some work within the tracker. 'work' should point to the work
+ * to queue, this will be copied (ownership doesn't pass). If pwork
+ * is not NULL then it will be set to point to the tracker's internal
+ * copy of the work.
+ *
* returns -EINVAL iff the work is already queued. -ENOMEM if the work
* couldn't be queued for another reason.
*/
@@ -33,11 +58,20 @@ int btracker_queue(struct background_tracker *b,
struct policy_work **pwork);
/*
+ * Hands out the next piece of work to be performed.
* Returns -ENODATA if there's no work.
*/
int btracker_issue(struct background_tracker *b, struct policy_work **work);
-void btracker_complete(struct background_tracker *b,
- struct policy_work *op);
+
+/*
+ * Informs the tracker that the work has been completed and it may forget
+ * about it.
+ */
+void btracker_complete(struct background_tracker *b, struct policy_work *op);
+
+/*
+ * Predicate to see if an origin block is already scheduled for promotion.
+ */
bool btracker_promotion_already_present(struct background_tracker *b,
dm_oblock_t oblock);