[DRBD-cvs] r1675 - in trunk: . drbd scripts user
svn at svn.drbd.org
svn at svn.drbd.org
Mon Dec 13 16:16:39 CET 2004
Author: phil
Date: 2004-12-13 16:16:36 +0100 (Mon, 13 Dec 2004)
New Revision: 1675
Modified:
trunk/
trunk/drbd/drbd_int.h
trunk/drbd/drbd_main.c
trunk/drbd/drbd_receiver.c
trunk/drbd/drbd_worker.c
trunk/scripts/drbd
trunk/user/drbd_limits.h
trunk/user/drbdadm.h
trunk/user/drbdadm_adjust.c
trunk/user/drbdadm_main.c
trunk/user/drbdsetup.c
Log:
svnp run. Investigated 1664 to 1675
r1667 by phil on 2004-12-06 14:40:49 +0100 (Mon, 06 Dec 2004)
Changed paths:
M /branches/drbd-0.7/user/drbd_limits.h
M /branches/drbd-0.7/user/drbdadm_main.c
Now drbdadm determines the minor_count correctly on udev/devfs
based system.
r1668 by phil on 2004-12-06 18:48:04 +0100 (Mon, 06 Dec 2004)
Changed paths:
M /branches/drbd-0.7/user/drbdadm_main.c
Hmmm, made my last change sane.
r1669 by phil on 2004-12-06 20:03:34 +0100 (Mon, 06 Dec 2004)
Changed paths:
M /branches/drbd-0.7/scripts/drbd
M /branches/drbd-0.7/user/drbdadm.h
M /branches/drbd-0.7/user/drbdadm_adjust.c
M /branches/drbd-0.7/user/drbdadm_main.c
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.
r1670 by phil on 2004-12-07 11:54:35 +0100 (Tue, 07 Dec 2004)
Changed paths:
M /branches/drbd-0.7/user/drbdsetup.c
Lars, lars... tsstss..
r1671 by phil on 2004-12-09 15:01:39 +0100 (Thu, 09 Dec 2004)
Changed paths:
M /branches/drbd-0.7/drbd/drbd_int.h
M /branches/drbd-0.7/drbd/drbd_main.c
M /branches/drbd-0.7/drbd/drbd_receiver.c
M /branches/drbd-0.7/drbd/drbd_worker.c
There was a race condition between attaching a device to its disk
and the starting of resync in receive_SyncParam().
This race caused the syncer to hit a BUG() macro in
mod_timer().
Fixed it.
r1672 by phil on 2004-12-09 15:02:20 +0100 (Thu, 09 Dec 2004)
Changed paths:
M /branches/drbd-0.7/scripts/drbd
Nicer progress indication.
r1674 by phil on 2004-12-13 14:37:28 +0100 (Mon, 13 Dec 2004)
Changed paths:
M /branches/drbd-0.7/drbd/drbd_worker.c
There was a bug in the sync-groups code:
When a sync was paused, it tried to activate the next sync
group, if there was no device in the current sync group syncing.
FIX:
Now w_resume_next_sg() only resumes the next sync group, if no
resources in the sg is syncing _and_ no resource in a lower
sg is syncing.
Property changes on: trunk
___________________________________________________________________
Name: propagate:at
- 1664
+ 1675
Modified: trunk/drbd/drbd_int.h
===================================================================
--- trunk/drbd/drbd_int.h 2004-12-13 13:37:28 UTC (rev 1674)
+++ trunk/drbd/drbd_int.h 2004-12-13 15:16:36 UTC (rev 1675)
@@ -966,7 +966,7 @@
extern int drbd_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg);
-// drbd_dsender.c
+// drbd_worker.c
extern int drbd_worker(struct Drbd_thread *thi);
extern void drbd_alter_sg(drbd_dev *mdev, int ng);
extern void drbd_start_resync(drbd_dev *mdev, drbd_conns_t side);
@@ -985,6 +985,7 @@
extern int w_try_send_barrier (drbd_dev *, struct drbd_work *, int);
extern int w_send_write_hint (drbd_dev *, struct drbd_work *, int);
extern int w_make_resync_request (drbd_dev *, struct drbd_work *, int);
+extern void resync_timer_fn(unsigned long data);
// drbd_receiver.c
extern int drbd_release_ee(drbd_dev* mdev,struct list_head* list);
Modified: trunk/drbd/drbd_main.c
===================================================================
--- trunk/drbd/drbd_main.c 2004-12-13 13:37:28 UTC (rev 1674)
+++ trunk/drbd/drbd_main.c 2004-12-13 15:16:36 UTC (rev 1675)
@@ -1456,6 +1456,8 @@
mdev->barrier_work.cb = w_try_send_barrier;
mdev->unplug_work.cb = w_send_write_hint;
init_timer(&mdev->resync_timer);
+ mdev->resync_timer.function = resync_timer_fn;
+ mdev->resync_timer.data = (unsigned long) mdev;
init_waitqueue_head(&mdev->cstate_wait);
init_waitqueue_head(&mdev->ee_wait);
Modified: trunk/drbd/drbd_receiver.c
===================================================================
--- trunk/drbd/drbd_receiver.c 2004-12-13 13:37:28 UTC (rev 1674)
+++ trunk/drbd/drbd_receiver.c 2004-12-13 15:16:36 UTC (rev 1675)
@@ -1367,6 +1367,8 @@
consider_sync = ((nconn=mdev->state.s.conn) == WFReportParams);
if(drbd_determin_dev_size(mdev)) consider_sync=0;
+ if(test_bit(DISKLESS, &mdev->flags)) consider_sync=0;
+
drbd_bm_unlock(mdev); // }
if(be32_to_cpu(p->flags)&1) {
Modified: trunk/drbd/drbd_worker.c
===================================================================
--- trunk/drbd/drbd_worker.c 2004-12-13 13:37:28 UTC (rev 1674)
+++ trunk/drbd/drbd_worker.c 2004-12-13 15:16:36 UTC (rev 1675)
@@ -310,7 +310,6 @@
PARANOIA_BUG_ON(w != &mdev->resync_work);
if(unlikely(cancel)) return 1;
- /* FIXME THINK what about w_resume_next_sg ?? */
if(unlikely(mdev->state.s.conn < Connected)) {
ERR("Confused in w_make_resync_request()! cstate < Connected");
@@ -406,9 +405,7 @@
drbd_md_write(mdev);
- /* FIXME
- * _queueing_ of w_resume_next_sg() gets _scheduled_ here.
- * maybe rather _do_ it right here instead? */
+
return 1;
}
@@ -644,11 +641,11 @@
for (i=0; i < minor_count; i++) {
odev = drbd_conf + i;
- if ( odev->sync_conf.group == mdev->sync_conf.group
+ if ( odev->sync_conf.group <= mdev->sync_conf.group
&& ( odev->state.s.conn == SyncSource ||
odev->state.s.conn == SyncTarget ) ) {
goto out; // Sync on an other device in this group
- // still runs.
+ // or a lower group still runs.
}
}
@@ -746,11 +743,6 @@
return;
}
- if (side == SyncTarget) {
- D_ASSERT(!test_bit(STOP_SYNC_TIMER,&mdev->flags));
- mod_timer(&mdev->resync_timer,jiffies);
- }
-
drbd_global_lock();
if ( mdev->state.s.conn == SyncTarget ||
mdev->state.s.conn == SyncSource ) {
@@ -764,6 +756,14 @@
* I really hate it that we can't have a consistent view of cstate.
*/
drbd_global_unlock();
+
+ if (mdev->cstate == SyncTarget) {
+ D_ASSERT(!test_bit(STOP_SYNC_TIMER,&mdev->flags));
+ mod_timer(&mdev->resync_timer,jiffies);
+ } else if (mdev->cstate == PausedSyncT) {
+ D_ASSERT(test_bit(STOP_SYNC_TIMER,&mdev->flags));
+ clear_bit(STOP_SYNC_TIMER,&mdev->flags);
+ }
}
int drbd_worker(struct Drbd_thread *thi)
@@ -775,9 +775,6 @@
sprintf(current->comm, "drbd%d_worker", (int)(mdev-drbd_conf));
- mdev->resync_timer.function = resync_timer_fn;
- mdev->resync_timer.data = (unsigned long) mdev;
-
for (;;) {
intr = down_interruptible(&mdev->data.work.s);
Modified: trunk/scripts/drbd
===================================================================
--- trunk/scripts/drbd 2004-12-13 13:37:28 UTC (rev 1674)
+++ trunk/scripts/drbd 2004-12-13 15:16:36 UTC (rev 1675)
@@ -51,19 +51,39 @@
done
}
+function adjust_with_progress
+{
+ IFS_O=$IFS
+ NEWLINE='
+'
+ IFS=$NEWLINE
+ local D=0
+ local S=0
+ local N=0
+
+ COMMANDS=`$DRBDADM -d adjust all` || exit 20
+ echo -n "[ "
+
+ for CMD in $COMMANDS; do
+ if echo $CMD | grep -q disk; then echo -n "d$D "; D=$(( D+1 ));
+ elif echo $CMD | grep -q syncer; then echo -n "s$S "; S=$(( S+1 ));
+ elif echo $CMD | grep -q net; then echo -n "n$N "; N=$(( N+1 ));
+ else echo echo -n ".. ";
+ fi
+ 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: trunk/user/drbd_limits.h
===================================================================
--- trunk/user/drbd_limits.h 2004-12-13 13:37:28 UTC (rev 1674)
+++ trunk/user/drbd_limits.h 2004-12-13 15:16:36 UTC (rev 1675)
@@ -20,7 +20,7 @@
const unsigned long long DRBD_ ## what ## _MAX = (max)
RANGE(MINOR_COUNT,1,255);
-RANGE(DIALOG_REFRESH,1,600);
+RANGE(DIALOG_REFRESH,0,600);
/* valid port number */
RANGE(PORT,1,0xffff);
@@ -50,7 +50,7 @@
RANGE(SNDBUF_SIZE, 1, 10000000);
/* arbitrary. */
- RANGE(MAX_BUFFERS, 32, 5000);
+ RANGE(MAX_BUFFERS, 32, 10000);
/* 0 is disabled.
* 200 should be more than enough even for very short timeouts */
Modified: trunk/user/drbdadm.h
===================================================================
--- trunk/user/drbdadm.h 2004-12-13 13:37:28 UTC (rev 1674)
+++ trunk/user/drbdadm.h 2004-12-13 15:16:36 UTC (rev 1675)
@@ -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: trunk/user/drbdadm_adjust.c
===================================================================
--- trunk/user/drbdadm_adjust.c 2004-12-13 13:37:28 UTC (rev 1674)
+++ trunk/user/drbdadm_adjust.c 2004-12-13 15:16:36 UTC (rev 1675)
@@ -336,12 +336,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: trunk/user/drbdadm_main.c
===================================================================
--- trunk/user/drbdadm_main.c 2004-12-13 13:37:28 UTC (rev 1674)
+++ trunk/user/drbdadm_main.c 2004-12-13 15:16:36 UTC (rev 1675)
@@ -67,6 +67,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;
@@ -107,6 +114,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' },
@@ -609,10 +663,11 @@
static int adm_up(struct d_resource* res,const 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)
@@ -658,7 +713,17 @@
struct stat sb;
if(stat(res->me->device,&sb)) {
- perror("stat");
+ // On udev/devfs based system the device nodes does not
+ // exist before the module is loaded. Therefore assume that
+ // the number in the device name is the minor number.
+ char *c;
+
+ c=res->me->device;
+ while(*c) {
+ if(isdigit(*c)) return strtol(c,NULL,10);
+ c++;
+ }
+ return 0;
}
return minor(sb.st_rdev);
@@ -1217,6 +1282,9 @@
nr_resources++;
}
+ // Just for the case that minor_of_res() returned 0 for all devices.
+ if( nr_resources > (highest_minor+1) ) highest_minor=nr_resources-1;
+
if( mc && mc<(highest_minor+1) ) {
fprintf(stderr,"The highest minor you have in your config is %d"
"but a minor_count of %d in your config!\n", highest_minor,mc);
@@ -1268,6 +1336,8 @@
}
}
+ run_dcmds();
+
free_config(config);
return rv;
Modified: trunk/user/drbdsetup.c
===================================================================
--- trunk/user/drbdsetup.c 2004-12-13 13:37:28 UTC (rev 1674)
+++ trunk/user/drbdsetup.c 2004-12-13 15:16:36 UTC (rev 1675)
@@ -470,7 +470,7 @@
break;
case 'b':
cn->config.max_buffers = m_strtoll_range(optarg,1, "max-buffers",
- DRBD_MAX_BUFFERS_MIN, DRBD_MAX_BUFFERS_MIN);
+ DRBD_MAX_BUFFERS_MIN, DRBD_MAX_BUFFERS_MAX);
break;
case 'c':
cn->config.try_connect_int = m_strtoll_range(optarg,1, "connect-int",
More information about the drbd-cvs
mailing list