Linux Audio

Check our new training course

Linux kernel drivers training

Mar 31-Apr 9, 2025, special US time zones
Register
Loading...
v6.2
 
 1/*
 2 * Copyright (C) 2017 Red Hat. All rights reserved.
 3 *
 4 * This file is released under the GPL.
 5 */
 6
 7#ifndef DM_CACHE_BACKGROUND_WORK_H
 8#define DM_CACHE_BACKGROUND_WORK_H
 9
10#include <linux/vmalloc.h>
11#include "dm-cache-policy.h"
12
13/*----------------------------------------------------------------*/
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15struct background_work;
16struct background_tracker;
17
18/*
19 * FIXME: discuss lack of locking in all methods.
 
 
 
 
 
 
 
 
20 */
21struct background_tracker *btracker_create(unsigned max_work);
22void btracker_destroy(struct background_tracker *b);
23
24unsigned btracker_nr_writebacks_queued(struct background_tracker *b);
25unsigned btracker_nr_demotions_queued(struct background_tracker *b);
26
27/*
 
 
 
 
 
28 * returns -EINVAL iff the work is already queued.  -ENOMEM if the work
29 * couldn't be queued for another reason.
30 */
31int btracker_queue(struct background_tracker *b,
32		   struct policy_work *work,
33		   struct policy_work **pwork);
34
35/*
 
36 * Returns -ENODATA if there's no work.
37 */
38int btracker_issue(struct background_tracker *b, struct policy_work **work);
39void btracker_complete(struct background_tracker *b,
40		       struct policy_work *op);
 
 
 
 
 
 
 
 
41bool btracker_promotion_already_present(struct background_tracker *b,
42					dm_oblock_t oblock);
43
44/*----------------------------------------------------------------*/
45
46#endif
v6.13.7
 1/* SPDX-License-Identifier: GPL-2.0-only */
 2/*
 3 * Copyright (C) 2017 Red Hat. All rights reserved.
 4 *
 5 * This file is released under the GPL.
 6 */
 7
 8#ifndef DM_CACHE_BACKGROUND_WORK_H
 9#define DM_CACHE_BACKGROUND_WORK_H
10
11#include <linux/vmalloc.h>
12#include "dm-cache-policy.h"
13
14/*----------------------------------------------------------------*/
15
16/*
17 * The cache policy decides what background work should be performed,
18 * such as promotions, demotions and writebacks. The core cache target
19 * is in charge of performing the work, and does so when it sees fit.
20 *
21 * The background_tracker acts as a go between. Keeping track of future
22 * work that the policy has decided upon, and handing (issuing) it to
23 * the core target when requested.
24 *
25 * There is no locking in this, so calls will probably need to be
26 * protected with a spinlock.
27 */
28
29struct bt_work {
30	struct list_head list;
31	struct rb_node node;
32	struct policy_work work;
33};
34
35extern struct kmem_cache *btracker_work_cache;
36
37struct background_work;
38struct background_tracker;
39
40/*
41 * Create a new tracker, it will not be able to queue more than
42 * 'max_work' entries.
43 */
44struct background_tracker *btracker_create(unsigned int max_work);
45
46/*
47 * Destroy the tracker. No issued, but not complete, work should
48 * exist when this is called. It is fine to have queued but unissued
49 * work.
50 */
 
51void btracker_destroy(struct background_tracker *b);
52
53unsigned int btracker_nr_demotions_queued(struct background_tracker *b);
 
54
55/*
56 * Queue some work within the tracker. 'work' should point to the work
57 * to queue, this will be copied (ownership doesn't pass).  If pwork
58 * is not NULL then it will be set to point to the tracker's internal
59 * copy of the work.
60 *
61 * returns -EINVAL iff the work is already queued.  -ENOMEM if the work
62 * couldn't be queued for another reason.
63 */
64int btracker_queue(struct background_tracker *b,
65		   struct policy_work *work,
66		   struct policy_work **pwork);
67
68/*
69 * Hands out the next piece of work to be performed.
70 * Returns -ENODATA if there's no work.
71 */
72int btracker_issue(struct background_tracker *b, struct policy_work **work);
73
74/*
75 * Informs the tracker that the work has been completed and it may forget
76 * about it.
77 */
78void btracker_complete(struct background_tracker *b, struct policy_work *op);
79
80/*
81 * Predicate to see if an origin block is already scheduled for promotion.
82 */
83bool btracker_promotion_already_present(struct background_tracker *b,
84					dm_oblock_t oblock);
85
86/*----------------------------------------------------------------*/
87
88#endif