Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 27922b4260f65d317aabda37e42bbbff > files > 1709

kernel-2.6.18-238.el5.src.rpm

From: heinzm@redhat.com <heinzm@redhat.com>
Date: Wed, 27 Aug 2008 14:16:41 +0200
Subject: [md] add device mapper dirty region hash
Message-id: 20080827121637.741316119@redhat.com
O-Subject: [PATCH RHEL5.3 437180 05/11] dm-region_hash.h.patch
Bugzilla: 437180

This patch introduces the device-mapper dirty region hash, which counts
amounts of writes in flight to any given region in the RAID sets address
space (ie. a region is a selectable 2^^N sector fraction of the total RAID
set size) and sits on top of the dirty region log (dm-log), in order to be
able to set a region in the dirty log to clean when the last write to
it finished.

Dirty region logging is mandatory on HA storage mappings (eg. RAID1,
RAID5) to allow for resynchronization of any dirty regions left behind
after an uncontrolled shutdown of the RAID set (eg. a system crash).

Heinz

Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>

diff --git a/drivers/md/dm-region_hash.h b/drivers/md/dm-region_hash.h
new file mode 100644
index 0000000..80e94ef
--- /dev/null
+++ b/drivers/md/dm-region_hash.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2003 Sistina Software Limited.
+ * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
+ *
+ * This file is released under the GPL.
+ */
+
+#ifndef DM_RH_H
+#define DM_RH_H
+
+#include "dm.h"
+#include "dm-bio-list.h"
+#include <linux/dm-dirty-log.h>
+
+/*-----------------------------------------------------------------
+ * Region hash
+ *----------------------------------------------------------------*/
+
+/*
+ * States a region can have.
+ */
+enum {
+	RH_CLEAN	= 0x01,	/* No writes in flight. */
+	RH_DIRTY	= 0x02,	/* Writes in flight. */
+	RH_NOSYNC	= 0x04,	/* Out of sync. */
+	RH_RECOVERING	= 0x08,	/* Under resynchronization. */
+	RH_ERROR	= 0x10,	/* Error recovering region */
+};
+
+/*
+ * Conversion fns
+ */
+region_t rh_bio_to_region(void *rh, struct bio *bio);
+region_t rh_sector_to_region(void *rh, sector_t sector);
+sector_t rh_region_to_sector(void *rh, region_t region);
+
+
+/*
+ * Functions to set a caller context in a region.
+ */
+void *rh_reg_get_context(void *reg);
+void rh_reg_set_context(void *reg, void *context);
+
+/*
+ * Reagion hash and region parameters.
+ */
+region_t rh_get_region_size(void *rh);
+sector_t rh_get_region_key(void *reg);
+
+int rh_init(void **rh,
+	    unsigned int max_recovery,
+	    void (*dispatch)(void *dispatch_context, struct bio_list *bios),
+	    void *dispatch_context,
+	    void (*wake)(void *wake_context),
+	    void *wake_context,
+	    struct dm_dirty_log *log, uint32_t region_size, region_t nr_regions);
+void rh_exit(void *rh);
+
+int rh_state(void *rh, region_t region, int may_block);
+void rh_update_states(void *rh);
+void rh_flush(void *rh);
+
+void rh_inc(void *rh, region_t region);
+void rh_inc_pending(void *rh, struct bio_list *bios);
+void rh_dec(void *rh, region_t region);
+void rh_delay(void *rh, struct bio *bio);
+void rh_delay_by_region(void *rh, struct bio *bio, region_t region);
+
+int rh_recovery_prepare(void *rh);
+void *rh_recovery_start(void *rh);
+void rh_recovery_end(void *reg, int error);
+void rh_stop_recovery(void *rh);
+void rh_start_recovery(void *rh);
+
+#endif