[DRBD-cvs] r1669 - in branches/drbd-0.7: scripts user
svn at svn.drbd.org
svn at svn.drbd.org
Mon Dec 6 20:03:36 CET 2004
Author: phil
Date: 2004-12-06 20:03:34 +0100 (Mon, 06 Dec 2004)
New Revision: 1669
Modified:
branches/drbd-0.7/scripts/drbd
branches/drbd-0.7/user/drbdadm.h
branches/drbd-0.7/user/drbdadm_adjust.c
branches/drbd-0.7/user/drbdadm_main.c
Log:
In setups with many devices we suffer from the following problem:
drbdsetup /dev/drbd0 disk ...
drbdsetup /dev/drbd0 syncer ...
drbdsetup /dev/drbd0 net ...
drbdsetup /dev/drbd1 disk ...
When "drbdsetup /dev/drbd1 disk ..." is finally executed the
resync of /dev/drbd0 is already running. This has the effect
that /dev/drbd1 has a hard time reading its bitmap from the
meta-data, because alle the available IO bandwith is satured
by the resync of /dev/drbd0.
Therefore we attach all resources to their disks first,
then do the syncer config of all, and at last connect
them to their peers.
Modified: branches/drbd-0.7/scripts/drbd
===================================================================
--- branches/drbd-0.7/scripts/drbd 2004-12-06 17:48:04 UTC (rev 1668)
+++ branches/drbd-0.7/scripts/drbd 2004-12-06 19:03:34 UTC (rev 1669)
@@ -51,19 +51,31 @@
done
}
+function adjust_with_progress
+{
+ IFS_O=$IFS
+ NEWLINE='
+'
+ IFS=$NEWLINE
+ COMMANDS=`$DRBDADM -d adjust all` || exit 20
+ echo -n "["
+
+ for CMD in $COMMANDS; do
+ echo -n "."
+ IFS=$IFS_O
+ $CMD
+ IFS=$NEWLINE
+ done
+ echo -n "]"
+
+ IFS=$IFS_O
+}
+
case "$1" in
start)
echo -n "Starting DRBD resources: "
assure_module_is_loaded
- RESOURCES=`$DRBDADM sh-resources` || exit 20
- for I in $RESOURCES; do
- if $DRBDADM adjust $I; then
- echo -n "[$I]"
- else
- echo -e "\n Failed setting up $I"
- exit 20
- fi
- done
+ adjust_with_progress
[ -d /var/lock/subsys ] && touch /var/lock/subsys/drbd # for RedHat
echo "."
$DRBDADM wait_con_int # User interruptible version of wait_connect all
Modified: branches/drbd-0.7/user/drbdadm.h
===================================================================
--- branches/drbd-0.7/user/drbdadm.h 2004-12-06 17:48:04 UTC (rev 1668)
+++ branches/drbd-0.7/user/drbdadm.h 2004-12-06 19:03:34 UTC (rev 1669)
@@ -77,6 +77,9 @@
extern void validate_resource(struct d_resource *);
extern int check_uniq(const char* what, const char *fmt, ...);
extern void verify_ips(struct d_resource* res);
+extern void schedule_dcmd( int (* function)(struct d_resource*,char* ),
+ struct d_resource* res,
+ int order);
extern char* config_file;
Modified: branches/drbd-0.7/user/drbdadm_adjust.c
===================================================================
--- branches/drbd-0.7/user/drbdadm_adjust.c 2004-12-06 17:48:04 UTC (rev 1668)
+++ branches/drbd-0.7/user/drbdadm_adjust.c 2004-12-06 19:03:34 UTC (rev 1669)
@@ -363,12 +363,12 @@
if (err) return err;
if(do_attach) {
- if( (rv=adm_attach(res,0)) ) return rv;
+ schedule_dcmd(adm_attach,res,0);
do_resize=0;
}
- if(do_resize) if( (rv=adm_resize(res,0)) ) return rv;
- if(do_syncer) if( (rv=adm_syncer(res,0)) ) return rv;
- if(do_connect) if( (rv=adm_connect(res,0))) return rv;
+ if(do_resize) schedule_dcmd(adm_resize,res,0);
+ if(do_syncer) schedule_dcmd(adm_syncer,res,1);
+ if(do_connect) schedule_dcmd(adm_connect,res,2);
return 0;
}
Modified: branches/drbd-0.7/user/drbdadm_main.c
===================================================================
--- branches/drbd-0.7/user/drbdadm_main.c 2004-12-06 17:48:04 UTC (rev 1668)
+++ branches/drbd-0.7/user/drbdadm_main.c 2004-12-06 19:03:34 UTC (rev 1669)
@@ -68,6 +68,13 @@
int res_name_required;
};
+struct deferred_cmd
+{
+ int (* function)(struct d_resource*,char* );
+ struct d_resource* res;
+ struct deferred_cmd* next;
+};
+
extern int yyparse();
extern FILE* yyin;
@@ -106,6 +113,53 @@
int soi=0;
volatile int alarm_raised;
+struct deferred_cmd *deferred_cmds[3] = { NULL, NULL, NULL };
+
+void schedule_dcmd( int (* function)(struct d_resource*,char* ),
+ struct d_resource* res,
+ int order)
+{
+ struct deferred_cmd *d;
+
+ if( (d = malloc(sizeof(struct deferred_cmd))) == NULL)
+ {
+ perror("waitpid");
+ exit(E_exec_error);
+ }
+
+ d->function = function;
+ d->res = res;
+ d->next = deferred_cmds[order];
+
+ deferred_cmds[order] = d;
+}
+
+int _run_dcmds(struct deferred_cmd *d)
+{
+ int rv;
+ if(d == NULL) return 0;
+
+ if(d->next == NULL)
+ {
+ rv = d->function(d->res,NULL);
+ free(d);
+ return rv;
+ }
+
+ rv = _run_dcmds(d->next);
+ if(!rv) rv |= d->function(d->res,NULL);
+ free(d);
+
+ return rv;
+}
+
+int run_dcmds(void)
+{
+ return _run_dcmds(deferred_cmds[0]) ||
+ _run_dcmds(deferred_cmds[1]) ||
+ _run_dcmds(deferred_cmds[2]);
+}
+
struct option admopt[] = {
{ "dry-run", no_argument, 0, 'd' },
{ "config-file", required_argument,0, 'c' },
@@ -573,10 +627,11 @@
static int adm_up(struct d_resource* res,char* unused)
{
- int r;
- if( (r=adm_attach(res,unused)) ) return r;
- if( (r=adm_syncer(res,unused)) ) return r;
- return adm_connect(res,unused);
+ schedule_dcmd(adm_attach,res,0);
+ schedule_dcmd(adm_syncer,res,1);
+ schedule_dcmd(adm_connect,res,2);
+
+ return 0;
}
static int on_primary(struct d_resource* res ,char* flag)
@@ -1240,6 +1295,8 @@
}
}
+ run_dcmds();
+
free_config(config);
return 0;
More information about the drbd-cvs
mailing list