[DRBD-cvs] r1440 - in trunk: . drbd testing/CTH testing/CTH/LGE_CTH
drbd-user@lists.linbit.com
drbd-user@lists.linbit.com
Fri, 16 Jul 2004 10:27:29 +0200 (CEST)
Author: lars
Date: 2004-07-16 10:27:21 +0200 (Fri, 16 Jul 2004)
New Revision: 1440
Modified:
trunk/Makefile
trunk/drbd/Kconfig
trunk/drbd/drbd_int.h
trunk/drbd/drbd_main.c
trunk/drbd/drbd_receiver.c
trunk/testing/CTH/LGE_CTH.pm
trunk/testing/CTH/LGE_CTH/DRBD_Resource.pm
Log:
* some fixes to the "make kernel-patch" target.
e.g. CONFIG_DRBD_MAJOR
* if drbd_major != nbd_major,
drbd_devfs_name is set to "drbd" on driver load...
* fixes to CTH perl version... slightly hackish.
Modified: trunk/Makefile
===================================================================
--- trunk/Makefile 2004-07-16 08:22:36 UTC (rev 1439)
+++ trunk/Makefile 2004-07-16 08:27:21 UTC (rev 1440)
@@ -135,9 +135,10 @@
sed -ne 's/^drbd_kernel_release "\(.*\)".*/\1/p')
kernel-patch:
- set -o noclobber; \
+ set -o errexit; \
kbase=$$(basename $(KDIR)); \
- d=patch-$$kbase-drbd-$(DIST_VERSION);\
+ d=patch-$$kbase-drbd-$(DIST_VERSION); \
+ test -e $$d && cp -fav --backup=numbered $$d $$d; \
bash scripts/patch-kernel $(KDIR) . > $$d
# maybe even dist/RPMS/$(ARCH) ?
Modified: trunk/drbd/Kconfig
===================================================================
--- trunk/drbd/Kconfig 2004-07-16 08:22:36 UTC (rev 1439)
+++ trunk/drbd/Kconfig 2004-07-16 08:27:21 UTC (rev 1440)
@@ -2,7 +2,7 @@
# DRBD device driver configuration
#
config BLK_DEV_DRBD
- tristate "Distributed redundant block device support"
+ tristate "DRBD Distributed replicated block device support"
select INET
select PROC_FS
---help---
@@ -16,7 +16,8 @@
state, 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/nbX). Every write is sent to the local 'lower level
- block device' and to the node with the device in 'secondary' state.
+ 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. Reads are always carried out locally.
@@ -26,6 +27,21 @@
If unsure, say N.
+config DRBD_MAJOR
+ int "DRBD device major number"
+ depends on BLK_DEV_DRBD
+ range 1 255
+ default 43
+ ---help---
+ Historically DRBD hijacked the NBD major number.
+ Until we get some number officially assigned to DRBD,
+ you can choose one here.
+ Typical values may be 100 or 219.
+
+ See also Documentation/devices.txt
+
+ If unsure, keep the default (43).
+
comment "DRBD in kernel, no NBD possible"
depends on BLK_DEV_DRBD=y
Modified: trunk/drbd/drbd_int.h
===================================================================
--- trunk/drbd/drbd_int.h 2004-07-16 08:22:36 UTC (rev 1439)
+++ trunk/drbd/drbd_int.h 2004-07-16 08:27:21 UTC (rev 1440)
@@ -44,9 +44,12 @@
extern int disable_io_hints;
extern int major_nr;
+// major == nbd_major ? "nbd" : "drbd";
+extern char* drbd_devfs_name;
+
/* Using the major_nr of the network block device
- prevents us from deadlocking with no request entries
- left on all_requests...
+ used to prevent us from deadlocking with no request entries
+ left on all_requests... those where the days...
look out for NBD_MAJOR in ll_rw_blk.c */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
@@ -71,11 +74,6 @@
#undef DEVICE_NAME
#define DEVICE_NAME "drbd"
-#define DEVFS_NAME "nbd" // This make sense as long as we are MAJOR 43
-/* FIXME we are no longer strictly MAJOR 43.
- * so, should this too become "configurable" ?
- * or shall we fix it to "drbd" ?
- */
// XXX do we need this?
#ifndef TRUE
Modified: trunk/drbd/drbd_main.c
===================================================================
--- trunk/drbd/drbd_main.c 2004-07-16 08:22:36 UTC (rev 1439)
+++ trunk/drbd/drbd_main.c 2004-07-16 08:27:21 UTC (rev 1440)
@@ -54,6 +54,10 @@
#include <linux/drbd.h>
#include "drbd_int.h"
+#ifndef CONFIG_DRBD_MAJOR
+#define CONFIG_DRBD_MAJOR NBD_MAJOR
+#endif
+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
# if defined(CONFIG_PPC64) || defined(CONFIG_SPARC64) || defined(CONFIG_X86_64)
extern int register_ioctl32_conversion(unsigned int cmd,
@@ -90,7 +94,7 @@
MODULE_AUTHOR("Philipp Reisner <phil@linbit.com>, Lars Ellenberg <lars@linbit.com>");
MODULE_DESCRIPTION("drbd - Distributed Replicated Block Device v" REL_VERSION);
MODULE_LICENSE("GPL");
-MODULE_PARM_DESC(major_nr, "Major nr to use -- default 43 (NBD_MAJOR)");
+MODULE_PARM_DESC(major_nr, "Major nr to use -- default " __stringify(CONFIG_DRBD_MAJOR) );
MODULE_PARM_DESC(minor_count, "Maximum number of drbd devices (1-255)");
MODULE_PARM_DESC(disable_io_hints, "Necessary if the loopback network device is used for DRBD" );
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
@@ -119,7 +123,7 @@
#endif
// module parameter, defined
-int major_nr = NBD_MAJOR;
+int major_nr = CONFIG_DRBD_MAJOR;
#ifdef MODULE
int minor_count = 2;
#else
@@ -128,6 +132,10 @@
// FIXME disable_io_hints shall die
int disable_io_hints = 0;
+// devfs name
+char* drbd_devfs_name = "nbd";
+
+
// global panic flag
volatile int drbd_did_panic = 0;
@@ -1578,7 +1586,7 @@
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
devfs_unregister(devfs_handle);
#else
- devfs_remove(DEVFS_NAME);
+ devfs_remove(drbd_devfs_name);
#endif
if (unregister_blkdev(MAJOR_NR, DEVICE_NAME) != 0)
@@ -1641,7 +1649,7 @@
#ifdef MODULE
return -EINVAL;
#else
- major_nr = NBD_MAJOR;
+ major_nr = CONFIG_DRBD_MAJOR;
#endif
}
@@ -1663,6 +1671,8 @@
return err;
}
+ drbd_devfs_name = (major_nr == NBD_MAJOR) ? "nbd" : "drbd";
+
/*
* allocate all necessary structs
*/
@@ -1680,7 +1690,7 @@
goto Enomem;
#else
- devfs_mk_dir(DEVFS_NAME);
+ devfs_mk_dir(drbd_devfs_name);
for (i = 0; i < minor_count; i++) {
drbd_dev *mdev = drbd_conf + i;
@@ -1703,12 +1713,13 @@
disk->first_minor = i;
disk->fops = &drbd_ops;
sprintf(disk->disk_name, DEVICE_NAME "%d", i);
- sprintf(disk->devfs_name, DEVFS_NAME "/%d", i);
+ sprintf(disk->devfs_name, "%s/%d", drbd_devf_sname, i);
disk->private_data = mdev;
add_disk(disk);
mdev->this_bdev = bdget(MKDEV(MAJOR_NR,i));
- mdev->this_bdev->bd_contains = mdev->this_bdev; // Hmmm ?
+ // we have no partitions. we contain only ourselves.
+ mdev->this_bdev->bd_contains = mdev->this_bdev;
if (bd_claim(mdev->this_bdev,drbd_sec_holder)) {
// Initial we are Secondary -> should claim myself.
WARN("Could not bd_claim() myself.");
Modified: trunk/drbd/drbd_receiver.c
===================================================================
--- trunk/drbd/drbd_receiver.c 2004-07-16 08:22:36 UTC (rev 1439)
+++ trunk/drbd/drbd_receiver.c 2004-07-16 08:27:21 UTC (rev 1440)
@@ -2013,7 +2013,7 @@
drbd_end_req(req, RQ_DRBD_SENT, 1, sector);
- if (mdev->rs_total &&
+ if (mdev->rs_total &&
mdev->conf.wire_protocol == DRBD_PROT_C)
drbd_set_in_sync(mdev,sector,blksize);
}
Modified: trunk/testing/CTH/LGE_CTH/DRBD_Resource.pm
===================================================================
--- trunk/testing/CTH/LGE_CTH/DRBD_Resource.pm 2004-07-16 08:22:36 UTC (rev 1439)
+++ trunk/testing/CTH/LGE_CTH/DRBD_Resource.pm 2004-07-16 08:27:21 UTC (rev 1440)
@@ -253,17 +253,18 @@
sub start {
my ($me,$node) = @_;
# FIXME paranoia: $node in peers, and up...
- my ($minor,$name) = @{$me->{_config}}{qw( minor name )};
+ my $c = $me->{_config};
+ my ($minor,$name) = @$c{qw( minor name )};
my ($hostname,$ip) = @{$node->{_config}}{qw/hostname admin_ip/};
my ($cmd,$force);
if ($me->{_config}->{do_once_per_node} and not $me->{"did_once:$node->{_id}"}++) {
- $cmd = "on $ip: $me->{_config}->{do_once_per_node} " . $me->env;
+ $cmd = "on $ip: $c->{do_once_per_node} " . $me->env;
_spawn("$me->{_id} do once per node on $node->{_id}", $cmd, 'SYNC');
}
if (not $me->{did_on_first_start}++) {
- if ($me->{_config}->{do_on_first_start}) {
- $cmd = "on $ip: $me->{_config}->{do_on_first_start} " . $me->env;
+ if ($c->{do_on_first_start}) {
+ $cmd = "on $ip: $c->{do_on_first_start} " . $me->env;
_spawn("$me->{_id} do on first start on $node->{_id}", $cmd, 'SYNC') if $cmd;
}
$force = 1;
@@ -275,6 +276,12 @@
$cmd = "on $ip: drbdadm_pri name=$name";
$cmd .= ' "force=-- -d"' if $force;
_spawn("$me->{_id}: Primary $name on $node->{_config}->{hostname}",$cmd,'SYNC');
+ if ($force) {
+ for my $i (@{$c->{_instances}}) {
+ $i->wait_sync("forced Primary")
+ if $c->{peers}->[$i->{_config}->{index}]->{node} == $node;
+ }
+ }
}
sub stop {
Modified: trunk/testing/CTH/LGE_CTH.pm
===================================================================
--- trunk/testing/CTH/LGE_CTH.pm 2004-07-16 08:22:36 UTC (rev 1439)
+++ trunk/testing/CTH/LGE_CTH.pm 2004-07-16 08:27:21 UTC (rev 1440)
@@ -7,11 +7,14 @@
require Exporter;
our @ISA = "Exporter";
our @EXPORT = (qw{ Configure Run Log });
-our @EXPORT_OK = (qw{ mytimestr _spawn pid_is_pending kill_if_pending });
+our @EXPORT_OK = (qw{
+ mytimestr _spawn pid_is_pending kill_if_pending
+ $DRBD_DEVNAME $DRBD_MAJOR $MINOR_COUNT
+ });
our %EXPORT_TAGS = (
util => [qw{
Log mytimestr _spawn pid_is_pending kill_if_pending
- DRBD_DEVNAME DRBD_MAJOR MINOR_COUNT
+ $DRBD_DEVNAME $DRBD_MAJOR $MINOR_COUNT
}], # for internal use only
);
@@ -226,7 +229,9 @@
wait_for_pending_events;
warn("\n.\n#\n#\tENTER MAINLOOP\n#\n");
+ warn "Failed: $FAILED\n";
+
my ($part,$event,$lasttime,@obj);
print STDERR "Event Obj:", map({ " $_->{_id}" } @EVENT_OBJ),"\n";