* [Drbd-dev] [DRBD-8] Update to drbdsetup events -a command
@ 2007-06-25 18:32 Graham, Simon
2007-06-26 10:01 ` Philipp Reisner
0 siblings, 1 reply; 2+ messages in thread
From: Graham, Simon @ 2007-06-25 18:32 UTC (permalink / raw)
To: drbd-dev
[-- Attachment #1.1: Type: text/plain, Size: 519 bytes --]
The drbdsetup events command starts off by outputting the current state
of the selected device - however, when you use '-a' to have it monitor
all devices, it would be useful if it would output the current state of
all devices - this removes the need to poll for state before running the
command. Attached is a suggested patch - probably a little too gross
since I just looped for all possible minor numbers 0-255; presumably we
should actually read the configured max from somewhere?
Simon
[-- Attachment #1.2: Type: text/html, Size: 2312 bytes --]
[-- Attachment #2: drbd-setup-events.patch --]
[-- Type: application/octet-stream, Size: 1425 bytes --]
Index: src/user/drbdsetup.c
===================================================================
--- src/user/drbdsetup.c (revision 15364)
+++ src/user/drbdsetup.c (working copy)
@@ -1183,6 +1183,10 @@
drbd_state_t state;
char* str;
+ /* Ignore error replies */
+ if (reply->ret_code != NoError)
+ return 1;
+
switch (reply->packet_type) {
case P_get_state:
if(consume_tag_int(T_state_i,reply->tag_list,(int*)&state.i)) {
@@ -1249,7 +1253,7 @@
struct drbd_tag_list *tl;
struct option *lo;
unsigned int seq=0;
- int sk_nl,c,cont=1,rr;
+ int sk_nl,c,cont=1,rr,i,last;
int unfiltered=0, all_devices=0;
int wfc_timeout=0, degr_wfc_timeout=0,timeout_ms;
struct timeval before,after;
@@ -1308,11 +1312,22 @@
timeout_ms= 1000 * ( rr ? degr_wfc_timeout : wfc_timeout) - 1;
// ask for the current state before waiting for state updates...
- tl->drbd_p_header->packet_type = P_get_state;
- tl->drbd_p_header->drbd_minor = minor;
- tl->drbd_p_header->flags = 0;
- send_cn(sk_nl,tl->nl_header,(char*)tl->tag_list_cpos-(char*)tl->nl_header);
+ if (all_devices) {
+ i = 0;
+ last = 255;
+ }
+ else {
+ i = last = minor;
+ }
+ while (i <= last) {
+ tl->drbd_p_header->packet_type = P_get_state;
+ tl->drbd_p_header->drbd_minor = i;
+ tl->drbd_p_header->flags = 0;
+ send_cn(sk_nl,tl->nl_header,(char*)tl->tag_list_cpos-(char*)tl->nl_header);
+ i++;
+ }
+
dt_unlock_drbd(lock_fd);
lock_fd=-1;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Drbd-dev] [DRBD-8] Update to drbdsetup events -a command
2007-06-25 18:32 [Drbd-dev] [DRBD-8] Update to drbdsetup events -a command Graham, Simon
@ 2007-06-26 10:01 ` Philipp Reisner
0 siblings, 0 replies; 2+ messages in thread
From: Philipp Reisner @ 2007-06-26 10:01 UTC (permalink / raw)
To: drbd-dev
On Monday 25 June 2007 20:32:14 Graham, Simon wrote:
> The drbdsetup events command starts off by outputting the current state
> of the selected device - however, when you use '-a' to have it monitor
> all devices, it would be useful if it would output the current state of
> all devices - this removes the need to poll for state before running the
> command. Attached is a suggested patch - probably a little too gross
> since I just looped for all possible minor numbers 0-255; presumably we
> should actually read the configured max from somewhere?
>
>
You are absolutely right with this two patches ...
The are in.
-phil
--
: Dipl-Ing Philipp Reisner Tel +43-1-8178292-50 :
: LINBIT Information Technologies GmbH Fax +43-1-8178292-82 :
: Vivenotgasse 48, 1120 Vienna, Austria http://www.linbit.com :
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-06-26 10:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-25 18:32 [Drbd-dev] [DRBD-8] Update to drbdsetup events -a command Graham, Simon
2007-06-26 10:01 ` Philipp Reisner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox