summaryrefslogtreecommitdiff
path: root/drivers/block
diff options
context:
space:
mode:
authorPhilipp Reisner <philipp.reisner@linbit.com>2009-04-09 14:25:19 +0200
committerPhilipp Reisner <philipp.reisner@linbit.com>2009-07-29 10:18:47 +0200
commitf83a37888aeeadddfa3c7d4cfa477bd156b3bbe6 (patch)
tree24ced73a200f0bef9726b0bf5c009211dc30ac22 /drivers/block
parent64189e310d1ce1a733f752bb24c9abec240ad0b3 (diff)
Cleanups triggered by the comments of Nikanth Karthikesan and Sam Ravnborg.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/drbd/Kconfig45
-rw-r--r--drivers/block/drbd/Makefile8
-rw-r--r--drivers/block/drbd/drbd_bitmap.c55
-rw-r--r--drivers/block/drbd/drbd_buildtag.c4
-rw-r--r--drivers/block/drbd/lru_cache.c2
5 files changed, 37 insertions, 77 deletions
diff --git a/drivers/block/drbd/Kconfig b/drivers/block/drbd/Kconfig
index 466cd36dc449..c5847ddb24b3 100644
--- a/drivers/block/drbd/Kconfig
+++ b/drivers/block/drbd/Kconfig
@@ -1,31 +1,36 @@
#
# DRBD device driver configuration
#
+
+comment "DRBD disabled because PROC_FS, INET or CONNECTOR not selected"
+ depends on !PROC_FS || !INET || !CONNECTOR
+
config BLK_DEV_DRBD
tristate "DRBD Distributed Replicated Block Device support"
- select INET
- select PROC_FS
- select CONNECTOR
- select CRYPTO
- select CRYPTO_HMAC
- ---help---
- DRBD is a block device which is designed to build high availability
- clusters. This is done by mirroring a whole block device via (a
- dedicated) network. You could see it as a network RAID 1.
-
- Each minor device has a state, which can be 'primary' or 'secondary'.
+ depends on PROC_FS && INET && CONNECTOR
+ help
+
+ NOTE: In order to authenticate connections you have to select
+ CRYPTO_HMAC and a hash function as well.
+
+ DRBD is a shared-nothing, synchronously replicated block device. It
+ is designed to serve as a building block for high availability
+ clusters and in this context, is a "drop-in" replacement for shared
+ storage. Simplistically, you could see it as a network RAID 1.
+
+ Each minor device has a role, which can be 'primary' or 'secondary'.
On the node with the primary device the application is supposed to
- run and to access the device (/dev/drbdX). Every write is sent to the
- local 'lower level block device' and via network to the node with the
- device in 'secondary' state.
- The secondary device simply writes the data to its lower level block
- device. Currently no read-balancing via the network is done.
+ run and to access the device (/dev/drbdX). Every write is sent to
+ the local 'lower level block device' and, across the network, to the
+ node with the device in 'secondary' state. The secondary device
+ simply writes the data to its lower level block device.
- DRBD can also be used with "shared-disk semantics" (primary-primary),
- even though it is a "shared-nothing cluster". You'd need to use a
- cluster file system on top of that for cache coherency.
+ DRBD can also be used in dual-Primary mode (device writable on both
+ nodes), which means it can exhibit shared disk semantics in a
+ shared-nothing cluster. Needless to say, on top of dual-Primary
+ DRBD utilizing a cluster file system is necessary to maintain for
+ cache coherency.
- DRBD management is done through user-space tools.
For automatic failover you need a cluster manager (e.g. heartbeat).
See also: http://www.drbd.org/, http://www.linux-ha.org
diff --git a/drivers/block/drbd/Makefile b/drivers/block/drbd/Makefile
index 6505d7eedb61..7237c339f7da 100644
--- a/drivers/block/drbd/Makefile
+++ b/drivers/block/drbd/Makefile
@@ -1,7 +1,5 @@
-#CFLAGS_drbd_sizeof_sanity_check.o = -Wpadded # -Werror
-
-drbd-objs := drbd_buildtag.o drbd_bitmap.o drbd_proc.o \
- drbd_worker.o drbd_receiver.o drbd_req.o drbd_actlog.o \
- lru_cache.o drbd_main.o drbd_strings.o drbd_nl.o
+drbd-y := drbd_buildtag.o drbd_bitmap.o drbd_proc.o
+drbd-y += drbd_worker.o drbd_receiver.o drbd_req.o drbd_actlog.o
+drbd-y += lru_cache.o drbd_main.o drbd_strings.o drbd_nl.o
obj-$(CONFIG_BLK_DEV_DRBD) += drbd.o
diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c
index 6704d79837df..fed1d1ebb7eb 100644
--- a/drivers/block/drbd/drbd_bitmap.c
+++ b/drivers/block/drbd/drbd_bitmap.c
@@ -78,8 +78,8 @@ struct drbd_bitmap {
};
/* definition of bits in bm_flags */
-#define BM_LOCKED 0
-#define BM_MD_IO_ERROR (BITS_PER_LONG-1) /* 31? 63? */
+#define BM_LOCKED 0
+#define BM_MD_IO_ERROR 1
static inline int bm_is_locked(struct drbd_bitmap *b)
{
@@ -148,23 +148,6 @@ void drbd_bm_unlock(struct drbd_conf *mdev)
up(&b->bm_change);
}
-#define bm_end_info(ignored...) ((void)(0))
-
-#if 0
-#define catch_oob_access_start() do { \
- do { \
- if ((bm-p_addr) >= PAGE_SIZE/sizeof(long)) { \
- printk(KERN_ALERT "drbd_bitmap.c:%u %s: p_addr:%p bm:%p %d\n", \
- __LINE__ , __func__ , p_addr, bm, (bm-p_addr)); \
- break; \
- }
-#define catch_oob_access_end() \
- } while (0); } while (0)
-#else
-#define catch_oob_access_start() do {
-#define catch_oob_access_end() } while (0)
-#endif
-
/* word offset to long pointer */
STATIC unsigned long *__bm_map_paddr(struct drbd_bitmap *b, unsigned long offset, const enum km_type km)
{
@@ -345,18 +328,14 @@ STATIC int bm_clear_surplus(struct drbd_bitmap *b)
p_addr = bm_map_paddr(b, w);
bm = p_addr + MLPP(w);
if (w < b->bm_words) {
- catch_oob_access_start();
cleared = hweight_long(*bm & ~mask);
*bm &= mask;
- catch_oob_access_end();
w++; bm++;
}
if (w < b->bm_words) {
- catch_oob_access_start();
cleared += hweight_long(*bm);
*bm = 0;
- catch_oob_access_end();
}
bm_unmap(p_addr);
return cleared;
@@ -371,16 +350,12 @@ STATIC void bm_set_surplus(struct drbd_bitmap *b)
p_addr = bm_map_paddr(b, w);
bm = p_addr + MLPP(w);
if (w < b->bm_words) {
- catch_oob_access_start();
*bm |= ~mask;
bm++; w++;
- catch_oob_access_end();
}
if (w < b->bm_words) {
- catch_oob_access_start();
*bm = ~(0UL);
- catch_oob_access_end();
}
bm_unmap(p_addr);
}
@@ -396,13 +371,11 @@ STATIC unsigned long __bm_count_bits(struct drbd_bitmap *b, const int swap_endia
p_addr = bm_map_paddr(b, offset);
bm = p_addr + MLPP(offset);
while (i--) {
- catch_oob_access_start();
#ifndef __LITTLE_ENDIAN
if (swap_endian)
*bm = lel_to_cpu(*bm);
#endif
bits += hweight_long(*bm++);
- catch_oob_access_end();
}
bm_unmap(p_addr);
offset += do_now;
@@ -463,14 +436,12 @@ STATIC void bm_memset(struct drbd_bitmap *b, size_t offset, int c, size_t len)
do_now = min_t(size_t, ALIGN(offset + 1, LWPP), end) - offset;
p_addr = bm_map_paddr(b, offset);
bm = p_addr + MLPP(offset);
- catch_oob_access_start();
if (bm+do_now > p_addr + LWPP) {
printk(KERN_ALERT "drbd: BUG BUG BUG! p_addr:%p bm:%p do_now:%d\n",
p_addr, bm, (int)do_now);
break; /* breaks to after catch_oob_access_end() only! */
}
memset(bm, c, do_now * sizeof(long));
- catch_oob_access_end();
bm_unmap(p_addr);
offset += do_now;
}
@@ -573,16 +544,13 @@ int drbd_bm_resize(struct drbd_conf *mdev, sector_t capacity)
p_addr = bm_map_paddr(b, words);
bm = p_addr + MLPP(words);
- catch_oob_access_start();
*bm = DRBD_MAGIC;
- catch_oob_access_end();
bm_unmap(p_addr);
(void)bm_clear_surplus(b);
if (!growing)
b->bm_set = bm_count_bits(b);
- bm_end_info(mdev, __func__);
spin_unlock_irq(&b->bm_lock);
if (opages != npages)
vfree(opages);
@@ -669,12 +637,10 @@ void drbd_bm_merge_lel(struct drbd_conf *mdev, size_t offset, size_t number,
bm = p_addr + MLPP(offset);
offset += do_now;
while (do_now--) {
- catch_oob_access_start();
bits = hweight_long(*bm);
word = *bm | lel_to_cpu(*buffer++);
*bm++ = word;
b->bm_set += hweight_long(word) - bits;
- catch_oob_access_end();
}
bm_unmap(p_addr);
}
@@ -683,10 +649,9 @@ void drbd_bm_merge_lel(struct drbd_conf *mdev, size_t offset, size_t number,
* where we _know_ that we are 64 bit aligned,
* and know that this function is used in this way, too...
*/
- if (end == b->bm_words) {
+ if (end == b->bm_words)
b->bm_set -= bm_clear_surplus(b);
- bm_end_info(mdev, __func__);
- }
+
spin_unlock_irq(&b->bm_lock);
}
@@ -719,11 +684,8 @@ void drbd_bm_get_lel(struct drbd_conf *mdev, size_t offset, size_t number,
p_addr = bm_map_paddr(b, offset);
bm = p_addr + MLPP(offset);
offset += do_now;
- while (do_now--) {
- catch_oob_access_start();
+ while (do_now--)
*buffer++ = cpu_to_lel(*bm++);
- catch_oob_access_end();
- }
bm_unmap(p_addr);
}
}
@@ -1249,11 +1211,8 @@ int drbd_bm_e_weight(struct drbd_conf *mdev, unsigned long enr)
int n = e-s;
p_addr = bm_map_paddr(b, s);
bm = p_addr + MLPP(s);
- while (n--) {
- catch_oob_access_start();
+ while (n--)
count += hweight_long(*bm++);
- catch_oob_access_end();
- }
bm_unmap(p_addr);
} else {
ERR("start offset (%d) too large in drbd_bm_e_weight\n", s);
@@ -1288,10 +1247,8 @@ unsigned long drbd_bm_ALe_set_all(struct drbd_conf *mdev, unsigned long al_enr)
p_addr = bm_map_paddr(b, s);
bm = p_addr + MLPP(s);
while (i--) {
- catch_oob_access_start();
count += hweight_long(*bm);
*bm = -1UL;
- catch_oob_access_end();
bm++;
}
bm_unmap(p_addr);
diff --git a/drivers/block/drbd/drbd_buildtag.c b/drivers/block/drbd/drbd_buildtag.c
index c78d252a889f..278f88474ece 100644
--- a/drivers/block/drbd/drbd_buildtag.c
+++ b/drivers/block/drbd/drbd_buildtag.c
@@ -2,6 +2,6 @@
#include <linux/drbd_config.h>
const char *drbd_buildtag(void)
{
- return "GIT-hash: c74771beb9598144d31b861e7ea966f914914c4f drbd/drbd_actlog.c drbd/drbd_bitmap.c drbd/drbd_int.h drbd/drbd_main.c drbd/drbd_receiver.c drbd/drbd_req.c drbd/drbd_worker.c"
- " build by phil@fat-tyre, 2009-03-30 16:54:38";
+ return "GIT-hash: bbadddd7bad33396ebb8c0c12da9aab594d00c4e drbd/Makefile-2.6"
+ " build by phil@fat-tyre, 2009-04-01 10:29:21";
}
diff --git a/drivers/block/drbd/lru_cache.c b/drivers/block/drbd/lru_cache.c
index 33fad4d3e358..98b89c1d4188 100644
--- a/drivers/block/drbd/lru_cache.c
+++ b/drivers/block/drbd/lru_cache.c
@@ -325,7 +325,7 @@ void lc_changed(struct lru_cache *lc, struct lc_element *e)
lc->new_number = -1;
clear_bit(__LC_DIRTY, &lc->flags);
smp_mb__after_clear_bit();
- PARANOIA_LEAVE();
+ RETURN();
}