[DRBD-cvs] svn commit by lars - r3035 - branches/drbd-8.0/user - prevent drbdmeta from trying to wipe out "just in case"

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Wed Aug 29 11:09:09 CEST 2007


Author: lars
Date: 2007-08-29 11:09:08 +0200 (Wed, 29 Aug 2007)
New Revision: 3035

Modified:
   branches/drbd-8.0/user/drbdmeta.c
Log:
prevent drbdmeta from trying to wipe out "just in case"
something that just is no there (device < 128MB).
the old drbdmeta is sooo ugly.
well, but the rewrite is still unfinished :(


Modified: branches/drbd-8.0/user/drbdmeta.c
===================================================================
--- branches/drbd-8.0/user/drbdmeta.c	2007-08-29 09:05:10 UTC (rev 3034)
+++ branches/drbd-8.0/user/drbdmeta.c	2007-08-29 09:09:08 UTC (rev 3035)
@@ -273,9 +273,9 @@
 	struct md_cpu md;
 
 	/* _byte_ offsets of our "super block" and other data, within fd */
-	u64 md_offset;
-	u64 al_offset;
-	u64 bm_offset;
+	s64 md_offset;
+	s64 al_offset;
+	s64 bm_offset;
 	size_t md_mmaped_length;
 	size_t al_mmaped_length;
 	size_t bm_mmaped_length;
@@ -684,14 +684,14 @@
 int v07_parse(struct format *cfg, char **argv, int argc, int *ai);
 int v07_md_initialize(struct format *cfg);
 void v07_md_erase_others(struct format *cfg);
-u64 v07_md_get_byte_offset(struct format * cfg);
+s64 v07_md_get_byte_offset(struct format * cfg);
 
 int v08_md_open(struct format *cfg);
 int v08_md_cpu_to_disk(struct format *cfg);
 int v08_md_disk_to_cpu(struct format *cfg);
 int v08_md_initialize(struct format *cfg);
 void v08_md_erase_others(struct format *cfg);
-u64 v08_md_get_byte_offset(struct format * cfg);
+s64 v08_md_get_byte_offset(struct format * cfg);
 
 struct format_ops f_ops[] = {
 	[Drbd_06] = {
@@ -881,7 +881,7 @@
 }
 
 int v07_style_md_open(struct format *cfg,
-		      u64 (*md_get_byte_offset) (struct format *),
+		      s64 (*md_get_byte_offset) (struct format *),
 		      size_t size)
 {
 	struct stat sb;
@@ -938,7 +938,7 @@
 	// For the case that someone modified la_sect by hand..
 	if( (cfg->md_index == DRBD_MD_INDEX_INTERNAL ||
 	     cfg->md_index == DRBD_MD_INDEX_FLEX_INT ) &&
-	    (cfg->md.la_sect*512 > cfg->md_offset) ) {
+	    (cfg->md.la_sect*512 > (u64)cfg->md_offset) ) {
 		printf("la-size-sect was too big, fixed.\n");
 		cfg->md.la_sect = cfg->md_offset/512;
 	}
@@ -972,7 +972,7 @@
 }
 
 void md_erase_sb(struct format *cfg,
-		 u64 (*md_get_byte_offset) (struct format *))
+		 s64 (*md_get_byte_offset) (struct format *))
 {
 	/* in case these are internal meta data, we need to
 	   make sure that there is no v08 superblock at the end
@@ -980,7 +980,7 @@
 
 	unsigned char zero_sector[512];
 	struct format cfg_f;
-	u64 offset;
+	s64 offset;
 	int bw;
 
 	if(cfg->md_index == DRBD_MD_INDEX_INTERNAL ||
@@ -992,6 +992,8 @@
 		   in the front of the meta data area. */
 
 		offset = md_get_byte_offset(&cfg_f);
+		if (offset < 0)
+			return;
 		if(lseek64(cfg->md_fd, offset, SEEK_SET) == -1) {
 			PERROR("lseek64() failed");
 			exit(20);
@@ -1404,9 +1406,9 @@
  begin of v07 {{{
  ******************************************/
 
-u64 v07_md_get_byte_offset(struct format *cfg)
+s64 v07_md_get_byte_offset(struct format *cfg)
 {
-	u64 offset;
+	s64 offset;
 
 	switch(cfg->md_index) {
 	default: /* external, some index */
@@ -1545,9 +1547,9 @@
  begin of v08 {{{
  ******************************************/
 
-u64 v08_md_get_byte_offset(struct format *cfg)
+s64 v08_md_get_byte_offset(struct format *cfg)
 {
-	u64 offset;
+	s64 offset;
 
 	switch(cfg->md_index) {
 	default: /* external, some index */



More information about the drbd-cvs mailing list