[DRBD-cvs] r1528 - in trunk: drbd testing

svn at svn.drbd.org svn at svn.drbd.org
Wed Sep 1 21:13:45 CEST 2004


Author: phil
Date: 2004-09-01 21:13:43 +0200 (Wed, 01 Sep 2004)
New Revision: 1528

Modified:
   trunk/drbd/drbd_int.h
   trunk/drbd/drbd_main.c
   trunk/testing/show_size.c
Log:
Fixed the overflow in the calculation of DRBD_MAX_SECTORS
Fixed testing/show_size.c to use the 64Bit ioctl.
I think it works now up to nearly 4TB.


Modified: trunk/drbd/drbd_int.h
===================================================================
--- trunk/drbd/drbd_int.h	2004-09-01 18:38:23 UTC (rev 1527)
+++ trunk/drbd/drbd_int.h	2004-09-01 19:13:43 UTC (rev 1528)
@@ -962,7 +962,7 @@
  */
 
 #define DRBD_MAX_SECTORS \
-          ( (MD_RESERVED_SIZE*2 - MD_BM_OFFSET) * (1<<(BM_EXT_SIZE_B-9)) )
+          ( (MD_RESERVED_SIZE*2LL - MD_BM_OFFSET) * (1LL<<(BM_EXT_SIZE_B-9)) )
 
 extern int  drbd_bm_init      (drbd_dev *mdev);
 extern int  drbd_bm_resize    (drbd_dev *mdev, sector_t sectors);

Modified: trunk/drbd/drbd_main.c
===================================================================
--- trunk/drbd/drbd_main.c	2004-09-01 18:38:23 UTC (rev 1527)
+++ trunk/drbd/drbd_main.c	2004-09-01 19:13:43 UTC (rev 1528)
@@ -1706,6 +1706,7 @@
 	SZO(Drbd_Data_Packet);
 	SZO(Drbd_BlockAck_Packet);
 	printk(KERN_ERR "AL_EXTENTS_PT = %d\n",AL_EXTENTS_PT);
+	printk(KERN_ERR "DRBD_MAX_SECTORS = %llu\n",DRBD_MAX_SECTORS);
 	return -EBUSY;
 #endif
 

Modified: trunk/testing/show_size.c
===================================================================
--- trunk/testing/show_size.c	2004-09-01 18:38:23 UTC (rev 1527)
+++ trunk/testing/show_size.c	2004-09-01 19:13:43 UTC (rev 1528)
@@ -22,6 +22,8 @@
 
  */
 
+typedef unsigned long long u64;
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
@@ -30,12 +32,12 @@
 #include <stdlib.h>
 #include <linux/fs.h>
 
-
 int main(int argc, char** argv)
 {
   int fd,err;
   struct stat drbd_stat;
-  long size;
+  u64 size64=0;
+  long size=0;
 
   if(argc != 2) 
     {
@@ -68,7 +70,18 @@
       perror("ioctl() failed");
     }
   
-  printf("Device size: %ld KB (%ld MB)\n",size/2,size/2048);
+  printf("BLKGETSIZE: %ld sectors: %ld KB   %ld MB  %ld GB\n",
+	 size, size/2,size/2048,size/2097152);
 
+  err=ioctl(fd,BLKGETSIZE64,&size64);
+  if(err)
+    {
+      perror("ioctl() failed");
+    }
+  
+  printf("BLKGETSIZE64: %llu byte: %llu KB   %llu MB  %llu GB  %llu TB \n",
+	 size64,size64/(1U<<10),size64/(1LU<<20),size64/(1LLU<<30),
+	 size64/(1LLU<<40));
+
   return 0;
 }



More information about the drbd-cvs mailing list