^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) #ifndef DM_CACHE_BACKGROUND_WORK_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #define DM_CACHE_BACKGROUND_WORK_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/vmalloc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include "dm-cache-policy.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) /*----------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) struct background_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) struct background_tracker;
^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) * FIXME: discuss lack of locking in all methods.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) struct background_tracker *btracker_create(unsigned max_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) void btracker_destroy(struct background_tracker *b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) unsigned btracker_nr_writebacks_queued(struct background_tracker *b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) unsigned btracker_nr_demotions_queued(struct background_tracker *b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * returns -EINVAL iff the work is already queued. -ENOMEM if the work
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * couldn't be queued for another reason.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) int btracker_queue(struct background_tracker *b,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct policy_work *work,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct policy_work **pwork);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * Returns -ENODATA if there's no work.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) int btracker_issue(struct background_tracker *b, struct policy_work **work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) void btracker_complete(struct background_tracker *b,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) struct policy_work *op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) bool btracker_promotion_already_present(struct background_tracker *b,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) dm_oblock_t oblock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) /*----------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #endif