[DRBD-cvs] r1821 - in branches/drbd-0.7: . drbd user
www-data
www-data at linbit.com
Thu Jun 30 11:44:29 CEST 2005
Author: lars
Date: 2005-06-30 11:44:27 +0200 (Thu, 30 Jun 2005)
New Revision: 1821
Modified:
branches/drbd-0.7/Makefile
branches/drbd-0.7/drbd/Makefile
branches/drbd-0.7/drbd/drbd_fs.c
branches/drbd-0.7/drbd/drbd_int.h
branches/drbd-0.7/user/drbdadm.h
branches/drbd-0.7/user/drbdadm_main.c
branches/drbd-0.7/user/drbdadm_parser.y
branches/drbd-0.7/user/drbdadm_scanner.fl
branches/drbd-0.7/user/drbdsetup.c
Log:
* make sure new la_size is written to meta data early
* test on feature instead of version code (TASK_ZOMBIE)
* add "verify_ips" flag to drbdadm commands, so it annoys us with warnings only part of the time.
* don't report the "is ip present" bash magic as failed command
* remove .tmp_versions on clean
* minor cleanups and adjustments
Modified: branches/drbd-0.7/Makefile
===================================================================
--- branches/drbd-0.7/Makefile 2005-06-30 07:55:38 UTC (rev 1820)
+++ branches/drbd-0.7/Makefile 2005-06-30 09:44:27 UTC (rev 1821)
@@ -38,7 +38,7 @@
endif
DIST_VERSION := $(subst -,_,$(REL_VERSION))
-FDIST_VERSION := $(shell sed -ne 's,^drbd-\([^/]*\)/.*,\1,p;q' < .filelist)
+FDIST_VERSION := $(shell test -e .filelist && sed -ne 's,^drbd-\([^/]*\)/.*,\1,p;q' < .filelist)
ifeq ($(FDIST_VERSION),)
FDIST_VERSION := $(DIST_VERSION)
endif
Modified: branches/drbd-0.7/drbd/Makefile
===================================================================
--- branches/drbd-0.7/drbd/Makefile 2005-06-30 07:55:38 UTC (rev 1820)
+++ branches/drbd-0.7/drbd/Makefile 2005-06-30 09:44:27 UTC (rev 1821)
@@ -131,6 +131,7 @@
endif
clean:
+ rm -rf .tmp_versions
rm -f *.[oas] *.ko .*.cmd .*.d .*.tmp *.mod.c .*.flags .depend .kernel*
distclean: clean
Modified: branches/drbd-0.7/drbd/drbd_fs.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_fs.c 2005-06-30 07:55:38 UTC (rev 1820)
+++ branches/drbd-0.7/drbd/drbd_fs.c 2005-06-30 09:44:27 UTC (rev 1821)
@@ -72,17 +72,29 @@
int drbd_determin_dev_size(struct Drbd_Conf* mdev)
{
sector_t pmdss; // previous meta data start sector
+ sector_t la_size;
+ int md_moved, la_size_changed;
int rv;
wait_event(mdev->al_wait, lc_try_lock(mdev->act_log));
pmdss = drbd_md_ss(mdev);
+ la_size = mdev->la_size;
+
rv = do_determin_dev_size(mdev);
- if ( pmdss != drbd_md_ss(mdev) && mdev->md_index == -1 ) {
+
+ la_size_changed = (la_size != mdev->la_size);
+ md_moved = (pmdss != drbd_md_ss(mdev) /* && mdev->md_index == -1 */);
+
+ if ( md_moved ) {
WARN("Moving meta-data.\n");
+ D_ASSERT(mdev->md_index == -1);
drbd_al_shrink(mdev); // All extents inactive.
drbd_bm_write(mdev); // write bitmap
- drbd_md_write(mdev); // Write mdev->la_size to disk.
}
+ if ( la_size_changed || md_moved ) {
+ // Write mdev->la_size to [possibly new position on] disk.
+ drbd_md_write(mdev);
+ }
lc_unlock(mdev->act_log);
return rv;
Modified: branches/drbd-0.7/drbd/drbd_int.h
===================================================================
--- branches/drbd-0.7/drbd/drbd_int.h 2005-06-30 07:55:38 UTC (rev 1820)
+++ branches/drbd-0.7/drbd/drbd_int.h 2005-06-30 09:44:27 UTC (rev 1821)
@@ -976,11 +976,15 @@
#define BM_EXT_PER_SECT ( 512 / BM_BYTES_PER_EXTENT ) // 4
*/
-#if ( !defined(CONFIG_LBD) ) && ( BITS_PER_LONG == 32 )
-# define DRBD_MAX_SECTORS (0xffffffffLU)
-#else
-# define DRBD_MAX_SECTORS \
+#define DRBD_MAX_SECTORS_32 (0xffffffffLU)
+#define DRBD_MAX_SECTORS_BM \
( (MD_RESERVED_SIZE*2LL - MD_BM_OFFSET) * (1LL<<(BM_EXT_SIZE_B-9)) )
+#if DRBD_MAX_SECTORS_BM < DRBD_MAX_SECTORS_32
+#define DRBD_MAX_SECTORS DRBD_MAX_SECTORS_BM
+#elif ( !defined(CONFIG_LBD) ) && ( BITS_PER_LONG == 32 )
+#define DRBD_MAX_SECTORS DRBD_MAX_SECTORS_32
+#else
+#define DRBD_MAX_SECTORS DRBD_MAX_SECTORS_BM
#endif
extern int drbd_bm_init (drbd_dev *mdev);
@@ -1553,7 +1557,7 @@
static inline void drbd_suicide(void)
{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
+#ifdef TASK_ZOMBIE
set_current_state(TASK_ZOMBIE);
#else
current->exit_state = EXIT_ZOMBIE;
Modified: branches/drbd-0.7/user/drbdadm.h
===================================================================
--- branches/drbd-0.7/user/drbdadm.h 2005-06-30 07:55:38 UTC (rev 1820)
+++ branches/drbd-0.7/user/drbdadm.h 2005-06-30 09:44:27 UTC (rev 1821)
@@ -19,6 +19,8 @@
RETURN_PID = 2,
SLEEPS_FOREVER = 4,
+
+ DONT_REPORT_FAILED = 0x80,
};
/* for check_uniq(): Check for uniqueness of certain values...
Modified: branches/drbd-0.7/user/drbdadm_main.c
===================================================================
--- branches/drbd-0.7/user/drbdadm_main.c 2005-06-30 07:55:38 UTC (rev 1820)
+++ branches/drbd-0.7/user/drbdadm_main.c 2005-06-30 09:44:27 UTC (rev 1821)
@@ -65,8 +65,9 @@
const char* name;
int (* function)(struct d_resource*,char* );
char* arg;
- int show_in_usage;
- int res_name_required;
+ int show_in_usage :1;
+ int res_name_required :1;
+ int verify_ips :1;
};
struct deferred_cmd
@@ -77,6 +78,7 @@
};
extern int yyparse();
+extern int yydebug;
extern FILE* yyin;
int adm_attach(struct d_resource* ,char* );
@@ -109,6 +111,7 @@
int highest_minor;
int config_valid=1;
int dry_run;
+int do_verify_ips;
char* drbdsetup;
char* setup_opts[10];
int soi=0;
@@ -169,34 +172,35 @@
};
struct adm_cmd cmds[] = {
- { "attach", adm_attach, 0 ,1,1 },
- { "detach", adm_generic_s,"detach" ,1,1 },
- { "connect", adm_connect, 0 ,1,1 },
- { "disconnect", adm_generic_s,"disconnect" ,1,1 },
- { "up", adm_up, 0 ,1,1 },
- { "down", adm_generic_s,"down" ,1,1 },
- { "primary", adm_primary, 0 ,1,1 },
- { "secondary", adm_generic_s,"secondary" ,1,1 },
- { "invalidate", adm_generic_l,"invalidate" ,1,1 },
- { "invalidate_remote", adm_generic_l,"invalidate_remote",1,1 },
- { "resize", adm_resize, 0 ,1,1 },
- { "syncer", adm_syncer, 0 ,1,1 },
- { "adjust", adm_adjust, 0 ,1,1 },
- { "wait_connect", adm_wait_c, 0 ,1,1 },
- { "state", adm_generic_s,"state" ,1,1 },
- { "cstate", adm_generic_s,"cstate" ,1,1 },
- { "dump", adm_dump, 0 ,1,1 },
- { "wait_con_int", adm_wait_ci, 0 ,1,0 },
- { "sh-resources", sh_resources,0 ,0,0 },
- { "sh-mod-parms", sh_mod_parms,0 ,0,0 },
- { "sh-dev", sh_dev, 0 ,0,1 },
- { "sh-ll-dev", sh_ll_dev, 0 ,0,1 },
- { "sh-md-dev", sh_md_dev, 0 ,0,1 },
- { "sh-md-idx", sh_md_idx, 0 ,0,1 }
+/* name, function, arg, show, needs res, verify_ips */
+ { "attach", adm_attach, 0 ,1,1,1 },
+ { "detach", adm_generic_s,"detach" ,1,1,1 },
+ { "connect", adm_connect, 0 ,1,1,1 },
+ { "disconnect", adm_generic_s,"disconnect" ,1,1,0 },
+ { "up", adm_up, 0 ,1,1,1 },
+ { "down", adm_generic_s,"down" ,1,1,0 },
+ { "primary", adm_primary, 0 ,1,1,1 },
+ { "secondary", adm_generic_s,"secondary" ,1,1,1 },
+ { "invalidate", adm_generic_l,"invalidate" ,1,1,1 },
+ { "invalidate_remote", adm_generic_l,"invalidate_remote",1,1,1 },
+ { "resize", adm_resize, 0 ,1,1,1 },
+ { "syncer", adm_syncer, 0 ,1,1,1 },
+ { "adjust", adm_adjust, 0 ,1,1,1 },
+ { "wait_connect", adm_wait_c, 0 ,1,1,1 },
+ { "state", adm_generic_s,"state" ,1,1,0 },
+ { "cstate", adm_generic_s,"cstate" ,1,1,1 },
+ { "dump", adm_dump, 0 ,1,1,1 },
+ { "wait_con_int", adm_wait_ci, 0 ,1,0,1 },
+ { "sh-resources", sh_resources,0 ,0,0,0 },
+ { "sh-mod-parms", sh_mod_parms,0 ,0,0,0 },
+ { "sh-dev", sh_dev, 0 ,0,1,0 },
+ { "sh-ll-dev", sh_ll_dev, 0 ,0,1,0 },
+ { "sh-md-dev", sh_md_dev, 0 ,0,1,0 },
+ { "sh-md-idx", sh_md_idx, 0 ,0,1,0 },
};
-#define ARRY_SIZE(A) (sizeof(A)/sizeof(A[0]))
+#define ARRY_SIZE(A) (int)(sizeof(A)/sizeof(A[0]))
/*** These functions are used to the print the config ***/
@@ -477,7 +481,7 @@
if( flags & SLEEPS_FINITE ) {
alarm(0);
sigaction(SIGALRM,&so,NULL);
- if(rv) {
+ if(rv && !(flags & DONT_REPORT_FAILED)) {
fprintf(stderr,"Command '");
while(*argv) {
fprintf(stderr,"%s",*argv++);
@@ -863,15 +867,21 @@
pids[i++]=m_system(argv,RETURN_PID);
}
- wtime = global_options.dialog_refresh ?
+ wtime = global_options.dialog_refresh ?
global_options.dialog_refresh : -1;
start = time(0);
- rr = gets_timeout(pids,0,0,3*1000); // no string, but timeout of 3 seconds.
- check_exit_codes(pids);
+ for (i = 0; i < 10; i++) {
+ // no string, but timeout
+ rr = gets_timeout(pids,0,0,1*1000);
+ if (rr < 0) break;
+ putchar('.');
+ fflush(stdout);
+ check_exit_codes(pids);
+ }
if(rr == 0) {
- printf("***************************************************************\n"
+ printf("\n***************************************************************\n"
" DRBD's startup script waits for the peer node(s) to appear.\n"
" - In case this node was already a degraded cluster before the\n"
" reboot the timeout is %s seconds. [degr-wfc-timeout]\n"
@@ -899,7 +909,6 @@
printf(" To abort waiting enter 'yes' [ -- ]:");
}
}
-
} while( rr != -1 );
printf("\n");
}
@@ -931,7 +940,7 @@
return buffer;
}
-void print_usage()
+void print_usage_and_exit(const char* addinfo)
{
int i;
struct option *opt;
@@ -963,6 +972,9 @@
printf("\nVersion: "REL_VERSION" (api:%d)\n%s\n",
API_VERSION, drbd_buildtag());
+ if (addinfo)
+ printf("\n%s\n",addinfo);
+
exit(E_usage);
}
@@ -975,7 +987,7 @@
char *argv[] = { "/bin/bash", "-c", NULL, "drbdadm:verify_ips", NULL };
int ex;
- if (dry_run == 1) return;
+ if (dry_run == 1 || do_verify_ips == 0) return;
if (!(res && res->me && res->me->address
&& res->peer && res->peer->address)) {
@@ -997,7 +1009,7 @@
"fi >/dev/null",
my_ip);
if (ex < 0) { perror("asprintf"); exit(E_thinko); }
- ex = m_system(argv,SLEEPS_SHORT);
+ ex = m_system(argv,SLEEPS_SHORT|DONT_REPORT_FAILED);
free(argv[2]); argv[2] = NULL;
if (ex != 0) {
@@ -1141,17 +1153,27 @@
int i,rv;
struct adm_cmd *cmd;
struct d_resource *res,*tmp;
+ char *env_drbd_nodename = NULL;
drbdsetup=NULL;
dry_run=0;
yyin=NULL;
uname(&nodeinfo); /* FIXME maybe fold to lower case ? */
+ env_drbd_nodename = getenv("__DRBD_NODE__");
+ if (env_drbd_nodename && *env_drbd_nodename) {
+ strncpy(nodeinfo.nodename,env_drbd_nodename,sizeof(nodeinfo.nodename)-1);
+ nodeinfo.nodename[sizeof(nodeinfo.nodename)] = 0;
+ fprintf(stderr, "\n"
+ " found __DRBD_NODE__ in environment\n"
+ " PRETENDING that I am >>%s<<\n\n",nodeinfo.nodename);
+ }
+
if( (progname=strrchr(argv[0],'/')) )
argv[0] = ++progname;
else
progname=argv[0];
- if(argc == 1) print_usage(); // arguments missing.
+ if(argc == 1) print_usage_and_exit("missing arguments"); // arguments missing.
opterr=1;
optind=0;
@@ -1190,18 +1212,19 @@
case '?':
// commented out, since opterr=1
//fprintf(stderr,"Unknown option %s\n",argv[optind-1]);
+ fprintf(stderr,"try '%s help'\n",progname);
return 20;
break;
}
}
- if ( optind == argc ) print_usage();
+ if ( optind == argc ) print_usage_and_exit(0);
while(argv[optind][0]=='-') {
setup_opts[soi++]=argv[optind++];
- if (optind == argc) print_usage();
+ if (optind == argc) print_usage_and_exit(0);
}
- if (optind == argc) print_usage();
+ if (optind == argc) print_usage_and_exit(0);
cmd=NULL;
for(i=0;i<ARRY_SIZE(cmds);i++) {
@@ -1212,10 +1235,12 @@
}
if(cmd==NULL) {
+ if (!strncmp("help",argv[optind],5)) print_usage_and_exit(0);
fprintf(stderr,"Unknown command '%s'.\n",argv[optind]);
exit(E_usage);
}
optind++;
+ do_verify_ips = cmd->verify_ips;
if (!config_file) {
i=0;
@@ -1255,11 +1280,17 @@
exit(E_exec_error);
};
+ //yydebug = 1;
yyparse();
if(!config_valid) exit(E_config_invalid);
- {
+ if (config == NULL) {
+ fprintf(stderr, "no resources defined!\n");
+ exit(0); /* THINK exit here? what code? */
+ }
+
+ { /* block for mc to avoid compiler warnings */
int mc=global_options.minor_count;
highest_minor=0;
@@ -1285,11 +1316,12 @@
if(cmd->res_name_required)
{
- if (optind + 1 > argc && cmd->function != adm_dump)
- print_usage (argv[0]); // arguments missing.
+ int is_dump = (cmd->function == adm_dump);
+ if (optind + 1 > argc && !is_dump)
+ print_usage_and_exit("missing arguments"); // arguments missing.
- if(optind==argc || !strcmp(argv[optind],"all")) {
- if (cmd->function == adm_dump) dump_global_info();
+ if ( optind==argc || !strcmp(argv[optind],"all") ) {
+ if (is_dump) dump_global_info();
for_each_resource(res,tmp,config) {
if( (rv=cmd->function(res,cmd->arg)) ) {
fprintf(stderr,"drbdsetup exited with code %d\n",rv);
Modified: branches/drbd-0.7/user/drbdadm_parser.y
===================================================================
--- branches/drbd-0.7/user/drbdadm_parser.y 2005-06-30 07:55:38 UTC (rev 1820)
+++ branches/drbd-0.7/user/drbdadm_parser.y 2005-06-30 09:44:27 UTC (rev 1821)
@@ -1,5 +1,7 @@
%{
+#define _GNU_SOURCE
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -10,6 +12,8 @@
extern void yyerror(char* text);
extern int yylex(void);
+#define YYDEBUG 1
+
#define APPEND(LIST,ITEM) ({ \
typeof((LIST)) _l = (LIST); \
typeof((ITEM)) _i = (ITEM); \
@@ -24,6 +28,7 @@
})
static struct d_resource* c_res;
+static struct d_resource* c_config;
static struct d_host_info* c_host;
static char* c_hostname;
static int c_section_start, n_hosts;
@@ -302,7 +307,7 @@
#define CHKU(what,val) \
c_host->what = val; \
- check_uniq( #what, "%s:%s",c_hostname,val)
+ check_uniq( #what, "%s:%s:%s", #what, c_hostname,val)
#define CHKS(sname) \
check_uniq(sname " section","%s:" sname, c_res->name)
@@ -360,8 +365,8 @@
}
;
-resources: /* empty */ { $$ = 0; }
- | resources resource { $$=APPEND($1,$2); }
+resources: /* empty */ { $$ = 0; c_config = 0; }
+ | resources resource { $$=APPEND($1,$2); c_config=$$; }
;
resource: TK_RESOURCE { n_hosts = 0; } resource_name res_stmts
Modified: branches/drbd-0.7/user/drbdadm_scanner.fl
===================================================================
--- branches/drbd-0.7/user/drbdadm_scanner.fl 2005-06-30 07:55:38 UTC (rev 1820)
+++ branches/drbd-0.7/user/drbdadm_scanner.fl 2005-06-30 09:44:27 UTC (rev 1821)
@@ -197,7 +197,8 @@
}
<IGNORE_SECTION>{
- [^{}] update_lcnt(); /* no ECHO */
+ [^{}\n]{1,80} /* no ECHO */
+ {WS} update_lcnt(); /* no ECHO */
\{ yy_push_state(IGNORE_SECTION);
}
Modified: branches/drbd-0.7/user/drbdsetup.c
===================================================================
--- branches/drbd-0.7/user/drbdsetup.c 2005-06-30 07:55:38 UTC (rev 1820)
+++ branches/drbd-0.7/user/drbdsetup.c 2005-06-30 09:44:27 UTC (rev 1821)
@@ -50,7 +50,7 @@
#include "drbd_limits.h"
-#define ARRY_SIZE(A) (sizeof(A)/sizeof(A[0]))
+#define ARRY_SIZE(A) (int)(sizeof(A)/sizeof(A[0]))
/* Default values */
#define DEF_NET_TIMEOUT 60 // 6 seconds
More information about the drbd-cvs
mailing list