[DRBD-cvs] svn commit by simon - r2796 - trunk/drbd - We've been
using the fault insertion code in DRBD-8 to
drbd-cvs at lists.linbit.com
drbd-cvs at lists.linbit.com
Wed Mar 14 15:59:57 CET 2007
Author: simon
Date: 2007-03-14 15:59:55 +0100 (Wed, 14 Mar 2007)
New Revision: 2796
Modified:
trunk/drbd/drbd_actlog.c
trunk/drbd/drbd_bitmap.c
trunk/drbd/drbd_compat_wrappers.h
trunk/drbd/drbd_int.h
trunk/drbd/drbd_main.c
trunk/drbd/drbd_receiver.c
trunk/drbd/drbd_req.c
Log:
We've been using the fault insertion code in DRBD-8 to simulate failures
and have found that it's a little too keen to insert faults - the
attached patch adds a new sysfs attribute, fault_devs, that can be used
to specify which devices are to have faults inserted (similar to
trace_devs). If this attribute is zero, then the behavior is as before -
faults will be inserted in all devices.
Modified: trunk/drbd/drbd_actlog.c
===================================================================
--- trunk/drbd/drbd_actlog.c 2007-03-13 17:33:19 UTC (rev 2795)
+++ trunk/drbd/drbd_actlog.c 2007-03-14 14:59:55 UTC (rev 2796)
@@ -34,7 +34,8 @@
* ;)
* this is mostly from drivers/md/md.c
*/
-STATIC int _drbd_md_sync_page_io(struct drbd_backing_dev *bdev,
+STATIC int _drbd_md_sync_page_io(drbd_dev *mdev,
+ struct drbd_backing_dev *bdev,
struct page *page, sector_t sector,
int rw, int size)
{
@@ -50,7 +51,7 @@
bio->bi_private = &event;
bio->bi_end_io = drbd_md_io_complete;
- if (FAULT_ACTIVE((rw & WRITE)? DRBD_FAULT_MD_WR:DRBD_FAULT_MD_RD)) {
+ if (FAULT_ACTIVE(mdev, (rw & WRITE)? DRBD_FAULT_MD_WR:DRBD_FAULT_MD_RD)) {
bio->bi_rw |= rw;
bio_endio(bio,bio->bi_size,-EIO);
}
@@ -112,7 +113,7 @@
void *p = page_address(mdev->md_io_page);
void *hp = page_address(mdev->md_io_tmpp);
- ok = _drbd_md_sync_page_io(bdev,iop,
+ ok = _drbd_md_sync_page_io(mdev, bdev,iop,
sector,READ,hardsect);
if (unlikely(!ok)) {
@@ -137,7 +138,7 @@
(unsigned long long)sector, rw ? "WRITE" : "READ");
}
- ok = _drbd_md_sync_page_io(bdev,iop,sector,rw,hardsect);
+ ok = _drbd_md_sync_page_io(mdev, bdev,iop,sector,rw,hardsect);
if (unlikely(!ok)) {
ERR("drbd_md_sync_page_io(,%llus,%s) failed!\n",
(unsigned long long)sector,rw ? "WRITE" : "READ");
@@ -683,7 +684,7 @@
/* all prepared, submit them */
for(i=0; bios[i]; i++) {
- if (FAULT_ACTIVE( DRBD_FAULT_MD_WR )) {
+ if (FAULT_ACTIVE( mdev, DRBD_FAULT_MD_WR )) {
bios[i]->bi_rw = WRITE;
bio_endio(bios[i],bios[i]->bi_size,-EIO);
} else {
Modified: trunk/drbd/drbd_bitmap.c
===================================================================
--- trunk/drbd/drbd_bitmap.c 2007-03-13 17:33:19 UTC (rev 2795)
+++ trunk/drbd/drbd_bitmap.c 2007-03-14 14:59:55 UTC (rev 2796)
@@ -654,7 +654,7 @@
bio->bi_private = b;
bio->bi_end_io = drbd_bm_async_io_complete;
- if (FAULT_ACTIVE((rw&WRITE)?DRBD_FAULT_MD_WR:DRBD_FAULT_MD_RD)) {
+ if (FAULT_ACTIVE(mdev, (rw&WRITE)?DRBD_FAULT_MD_WR:DRBD_FAULT_MD_RD)) {
bio->bi_rw |= rw;
bio_endio(bio,bio->bi_size,-EIO);
}
Modified: trunk/drbd/drbd_compat_wrappers.h
===================================================================
--- trunk/drbd/drbd_compat_wrappers.h 2007-03-13 17:33:19 UTC (rev 2795)
+++ trunk/drbd/drbd_compat_wrappers.h 2007-03-14 14:59:55 UTC (rev 2796)
@@ -120,18 +120,19 @@
/*
* used to submit our private bio
*/
-static inline void drbd_generic_make_request(int rw, int fault_type, struct bio *bio)
+static inline void drbd_generic_make_request(drbd_dev *mdev, int rw, int fault_type, struct bio *bio)
{
bio->bi_rw = rw; // on the receiver side, e->..rw was not yet defined.
if (!bio->bi_bdev) {
- printk(KERN_ERR "drbd_generic_make_request: bio->bi_bdev == NULL\n");
+ printk(KERN_ERR DEVICE_NAME "%d: drbd_generic_make_request: bio->bi_bdev == NULL\n",
+ mdev_to_minor(mdev));
dump_stack();
bio_endio(bio, bio->bi_size, -ENODEV);
return;
}
- if (FAULT_ACTIVE(fault_type))
+ if (FAULT_ACTIVE(mdev, fault_type))
bio_endio(bio,bio->bi_size,-EIO);
else
generic_make_request(bio);
Modified: trunk/drbd/drbd_int.h
===================================================================
--- trunk/drbd/drbd_int.h 2007-03-13 17:33:19 UTC (rev 2795)
+++ trunk/drbd/drbd_int.h 2007-03-14 14:59:55 UTC (rev 2796)
@@ -48,6 +48,7 @@
#ifdef DRBD_ENABLE_FAULTS
extern int enable_faults;
extern int fault_rate;
+extern int fault_devs;
#endif
#include <linux/major.h>
@@ -208,12 +209,17 @@
};
#ifdef DRBD_ENABLE_FAULTS
-#define FAULT_ACTIVE(_t) \
- (fault_rate && (enable_faults & (1<<(_t))) && _drbd_insert_fault(_t))
+extern unsigned int _drbd_insert_fault(drbd_dev *mdev, unsigned int type);
+static inline int
+drbd_insert_fault(drbd_dev *mdev, unsigned int type) {
+ return (fault_rate &&
+ (enable_faults & (1<<type)) &&
+ _drbd_insert_fault(mdev,type));
+}
+#define FAULT_ACTIVE(_m, _t) (drbd_insert_fault((_m),(_t)))
-extern unsigned int _drbd_insert_fault(unsigned int type);
#else
-#define FAULT_ACTIVE(_t) (0)
+#define FAULT_ACTIVE(_m, _t) (0)
#endif
#include <linux/stringify.h>
Modified: trunk/drbd/drbd_main.c
===================================================================
--- trunk/drbd/drbd_main.c 2007-03-13 17:33:19 UTC (rev 2795)
+++ trunk/drbd/drbd_main.c 2007-03-14 14:59:55 UTC (rev 2796)
@@ -96,9 +96,11 @@
int enable_faults = 0;
int fault_rate;
int fault_count;
+int fault_devs;
module_param(enable_faults,int,0664); // bitmap of enabled faults
module_param(fault_rate,int,0664); // fault rate % value - applies to all enabled faults
module_param(fault_count,int,0664); // count of faults inserted
+module_param(fault_devs,int,0644); // bitmap of devices to insert faults on
#endif
// module parameter, defined
@@ -2869,18 +2871,19 @@
}
unsigned int
-_drbd_insert_fault(unsigned int type)
+_drbd_insert_fault(drbd_dev *mdev, unsigned int type)
{
static struct fault_random_state rrs = {0,0};
- unsigned int rnd = ((_drbd_fault_random(&rrs) % 100) + 1);
- unsigned int ret = (rnd <= fault_rate);
+ unsigned int ret = (
+ (fault_devs == 0 || ((1 << mdev_to_minor(mdev)) & fault_devs) != 0) &&
+ (((_drbd_fault_random(&rrs) % 100) + 1) <= fault_rate));
if (ret) {
fault_count++;
if (printk_ratelimit())
- printk(KERN_ALERT "Simulating %s failure\n", _drbd_fault_str(type));
+ WARN("***Simulating %s failure\n", _drbd_fault_str(type));
}
return ret;
Modified: trunk/drbd/drbd_receiver.c
===================================================================
--- trunk/drbd/drbd_receiver.c 2007-03-13 17:33:19 UTC (rev 2795)
+++ trunk/drbd/drbd_receiver.c 2007-03-14 14:59:55 UTC (rev 2796)
@@ -1065,7 +1065,7 @@
return ok;
}
-STATIC int recv_resync_read(drbd_dev *mdev,sector_t sector, int data_size)
+STATIC int recv_resync_read(drbd_dev *mdev,sector_t sector,int data_size)
{
struct Tl_epoch_entry *e;
@@ -1089,7 +1089,7 @@
INFO("submit EE (RS)WRITE sec=%llus size=%u ee=%p\n",
(unsigned long long)e->sector,e->size,e);
);
- drbd_generic_make_request(WRITE,DRBD_FAULT_RS_WR,e->private_bio);
+ drbd_generic_make_request(mdev,WRITE,DRBD_FAULT_RS_WR,e->private_bio);
/* accounting done in endio */
maybe_kick_lo(mdev);
@@ -1587,7 +1587,7 @@
(unsigned long long)e->sector,e->size,e);
);
/* FIXME drbd_al_begin_io in case we have two primaries... */
- drbd_generic_make_request(WRITE,DRBD_FAULT_DT_WR,e->private_bio);
+ drbd_generic_make_request(mdev,WRITE,DRBD_FAULT_DT_WR,e->private_bio);
/* accounting done in endio */
maybe_kick_lo(mdev);
@@ -1683,7 +1683,7 @@
(unsigned long long)e->sector,e->size,e);
);
/* FIXME actually, it could be a READA originating from the peer ... */
- drbd_generic_make_request(READ,fault_type,e->private_bio);
+ drbd_generic_make_request(mdev,READ,fault_type,e->private_bio);
maybe_kick_lo(mdev);
return TRUE;
Modified: trunk/drbd/drbd_req.c
===================================================================
--- trunk/drbd/drbd_req.c 2007-03-13 17:33:19 UTC (rev 2795)
+++ trunk/drbd/drbd_req.c 2007-03-14 14:59:55 UTC (rev 2796)
@@ -1011,9 +1011,9 @@
* was not detached below us? */
req->private_bio->bi_bdev = mdev->bc->backing_bdev;
- if (FAULT_ACTIVE(rw==WRITE ? DRBD_FAULT_DT_WR :
- ( rw==READ ? DRBD_FAULT_DT_RD :
- DRBD_FAULT_DT_RA ) ))
+ if (FAULT_ACTIVE(mdev, rw==WRITE ? DRBD_FAULT_DT_WR :
+ ( rw==READ ? DRBD_FAULT_DT_RD :
+ DRBD_FAULT_DT_RA ) ))
bio_endio(req->private_bio, req->private_bio->bi_size, -EIO);
else
generic_make_request(req->private_bio);
More information about the drbd-cvs
mailing list