Linux Audio

Check our new training course

Loading...
v5.14.15
 
  1/*
  2 * Copyright (C) 2003 Sistina Software Limited.
  3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
  4 *
  5 * Device-Mapper dirty region hash interface.
  6 *
  7 * This file is released under the GPL.
  8 */
  9
 10#ifndef DM_REGION_HASH_H
 11#define DM_REGION_HASH_H
 12
 13#include <linux/dm-dirty-log.h>
 14
 15/*-----------------------------------------------------------------
 
 16 * Region hash
 17 *----------------------------------------------------------------*/
 
 18struct dm_region_hash;
 19struct dm_region;
 20
 21/*
 22 * States a region can have.
 23 */
 24enum dm_rh_region_states {
 25	DM_RH_CLEAN	 = 0x01,	/* No writes in flight. */
 26	DM_RH_DIRTY	 = 0x02,	/* Writes in flight. */
 27	DM_RH_NOSYNC	 = 0x04,	/* Out of sync. */
 28	DM_RH_RECOVERING = 0x08,	/* Under resynchronization. */
 29};
 30
 31/*
 32 * Region hash create/destroy.
 33 */
 34struct bio_list;
 35struct dm_region_hash *dm_region_hash_create(
 36		void *context, void (*dispatch_bios)(void *context,
 37						     struct bio_list *bios),
 38		void (*wakeup_workers)(void *context),
 39		void (*wakeup_all_recovery_waiters)(void *context),
 40		sector_t target_begin, unsigned max_recovery,
 41		struct dm_dirty_log *log, uint32_t region_size,
 42		region_t nr_regions);
 43void dm_region_hash_destroy(struct dm_region_hash *rh);
 44
 45struct dm_dirty_log *dm_rh_dirty_log(struct dm_region_hash *rh);
 46
 47/*
 48 * Conversion functions.
 49 */
 50region_t dm_rh_bio_to_region(struct dm_region_hash *rh, struct bio *bio);
 51sector_t dm_rh_region_to_sector(struct dm_region_hash *rh, region_t region);
 52void *dm_rh_region_context(struct dm_region *reg);
 53
 54/*
 55 * Get region size and key (ie. number of the region).
 56 */
 57sector_t dm_rh_get_region_size(struct dm_region_hash *rh);
 58region_t dm_rh_get_region_key(struct dm_region *reg);
 59
 60/*
 61 * Get/set/update region state (and dirty log).
 62 *
 63 */
 64int dm_rh_get_state(struct dm_region_hash *rh, region_t region, int may_block);
 65void dm_rh_set_state(struct dm_region_hash *rh, region_t region,
 66		     enum dm_rh_region_states state, int may_block);
 67
 68/* Non-zero errors_handled leaves the state of the region NOSYNC */
 69void dm_rh_update_states(struct dm_region_hash *rh, int errors_handled);
 70
 71/* Flush the region hash and dirty log. */
 72int dm_rh_flush(struct dm_region_hash *rh);
 73
 74/* Inc/dec pending count on regions. */
 75void dm_rh_inc_pending(struct dm_region_hash *rh, struct bio_list *bios);
 76void dm_rh_dec(struct dm_region_hash *rh, region_t region);
 77
 78/* Delay bios on regions. */
 79void dm_rh_delay(struct dm_region_hash *rh, struct bio *bio);
 80
 81void dm_rh_mark_nosync(struct dm_region_hash *rh, struct bio *bio);
 82
 83/*
 84 * Region recovery control.
 85 */
 86
 87/* Prepare some regions for recovery by starting to quiesce them. */
 88void dm_rh_recovery_prepare(struct dm_region_hash *rh);
 89
 90/* Try fetching a quiesced region for recovery. */
 91struct dm_region *dm_rh_recovery_start(struct dm_region_hash *rh);
 92
 93/* Report recovery end on a region. */
 94void dm_rh_recovery_end(struct dm_region *reg, int error);
 95
 96/* Returns number of regions with recovery work outstanding. */
 97int dm_rh_recovery_in_flight(struct dm_region_hash *rh);
 98
 99/* Start/stop recovery. */
100void dm_rh_start_recovery(struct dm_region_hash *rh);
101void dm_rh_stop_recovery(struct dm_region_hash *rh);
102
103#endif /* DM_REGION_HASH_H */
v6.9.4
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2/*
  3 * Copyright (C) 2003 Sistina Software Limited.
  4 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
  5 *
  6 * Device-Mapper dirty region hash interface.
  7 *
  8 * This file is released under the GPL.
  9 */
 10
 11#ifndef DM_REGION_HASH_H
 12#define DM_REGION_HASH_H
 13
 14#include <linux/dm-dirty-log.h>
 15
 16/*
 17 *----------------------------------------------------------------
 18 * Region hash
 19 *----------------------------------------------------------------
 20 */
 21struct dm_region_hash;
 22struct dm_region;
 23
 24/*
 25 * States a region can have.
 26 */
 27enum dm_rh_region_states {
 28	DM_RH_CLEAN	 = 0x01,	/* No writes in flight. */
 29	DM_RH_DIRTY	 = 0x02,	/* Writes in flight. */
 30	DM_RH_NOSYNC	 = 0x04,	/* Out of sync. */
 31	DM_RH_RECOVERING = 0x08,	/* Under resynchronization. */
 32};
 33
 34/*
 35 * Region hash create/destroy.
 36 */
 37struct bio_list;
 38struct dm_region_hash *dm_region_hash_create(
 39		void *context, void (*dispatch_bios)(void *context,
 40						     struct bio_list *bios),
 41		void (*wakeup_workers)(void *context),
 42		void (*wakeup_all_recovery_waiters)(void *context),
 43		sector_t target_begin, unsigned int max_recovery,
 44		struct dm_dirty_log *log, uint32_t region_size,
 45		region_t nr_regions);
 46void dm_region_hash_destroy(struct dm_region_hash *rh);
 47
 48struct dm_dirty_log *dm_rh_dirty_log(struct dm_region_hash *rh);
 49
 50/*
 51 * Conversion functions.
 52 */
 53region_t dm_rh_bio_to_region(struct dm_region_hash *rh, struct bio *bio);
 54sector_t dm_rh_region_to_sector(struct dm_region_hash *rh, region_t region);
 55void *dm_rh_region_context(struct dm_region *reg);
 56
 57/*
 58 * Get region size and key (ie. number of the region).
 59 */
 60sector_t dm_rh_get_region_size(struct dm_region_hash *rh);
 61region_t dm_rh_get_region_key(struct dm_region *reg);
 62
 63/*
 64 * Get/set/update region state (and dirty log).
 65 *
 66 */
 67int dm_rh_get_state(struct dm_region_hash *rh, region_t region, int may_block);
 68void dm_rh_set_state(struct dm_region_hash *rh, region_t region,
 69		     enum dm_rh_region_states state, int may_block);
 70
 71/* Non-zero errors_handled leaves the state of the region NOSYNC */
 72void dm_rh_update_states(struct dm_region_hash *rh, int errors_handled);
 73
 74/* Flush the region hash and dirty log. */
 75int dm_rh_flush(struct dm_region_hash *rh);
 76
 77/* Inc/dec pending count on regions. */
 78void dm_rh_inc_pending(struct dm_region_hash *rh, struct bio_list *bios);
 79void dm_rh_dec(struct dm_region_hash *rh, region_t region);
 80
 81/* Delay bios on regions. */
 82void dm_rh_delay(struct dm_region_hash *rh, struct bio *bio);
 83
 84void dm_rh_mark_nosync(struct dm_region_hash *rh, struct bio *bio);
 85
 86/*
 87 * Region recovery control.
 88 */
 89
 90/* Prepare some regions for recovery by starting to quiesce them. */
 91void dm_rh_recovery_prepare(struct dm_region_hash *rh);
 92
 93/* Try fetching a quiesced region for recovery. */
 94struct dm_region *dm_rh_recovery_start(struct dm_region_hash *rh);
 95
 96/* Report recovery end on a region. */
 97void dm_rh_recovery_end(struct dm_region *reg, int error);
 98
 99/* Returns number of regions with recovery work outstanding. */
100int dm_rh_recovery_in_flight(struct dm_region_hash *rh);
101
102/* Start/stop recovery. */
103void dm_rh_start_recovery(struct dm_region_hash *rh);
104void dm_rh_stop_recovery(struct dm_region_hash *rh);
105
106#endif /* DM_REGION_HASH_H */