[DRBD-cvs] drbd by phil; Code to make it impossible to overflow t...
drbd-user@lists.linbit.com
drbd-user@lists.linbit.com
Mon, 7 Jun 2004 14:58:43 +0200 (CEST)
DRBD CVS committal
Author : phil
Module : drbd
Dir : drbd/drbd
Modified Files:
Tag: rel-0_7-branch
drbd_actlog.c drbd_fs.c drbd_int.h
Log Message:
Code to make it impossible to overflow the activity log.
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/drbd/Attic/drbd_actlog.c,v
retrieving revision 1.1.2.103
retrieving revision 1.1.2.104
diff -u -3 -r1.1.2.103 -r1.1.2.104
--- drbd_actlog.c 1 Jun 2004 07:00:57 -0000 1.1.2.103
+++ drbd_actlog.c 7 Jun 2004 12:58:38 -0000 1.1.2.104
@@ -28,8 +28,6 @@
#include <linux/drbd.h>
#include "drbd_int.h"
-#define AL_EXTENTS_PT 61
-
/* This is what I like so much about the linux kernel:
* if you have a close look, you can almost always reuse code by someone else
* ;)
@@ -289,6 +287,7 @@
if( ++mdev->al_tr_pos > div_ceil(mdev->act_log->nr_elements,AL_EXTENTS_PT) ) {
mdev->al_tr_pos=0;
}
+ D_ASSERT(mdev->al_tr_pos < MD_AL_MAX_SIZE);
mdev->al_tr_number++;
up(&mdev->md_io_mutex);
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/drbd/drbd_fs.c,v
retrieving revision 1.28.2.100
retrieving revision 1.28.2.101
diff -u -3 -r1.28.2.100 -r1.28.2.101
--- drbd_fs.c 1 Jun 2004 14:29:06 -0000 1.28.2.100
+++ drbd_fs.c 7 Jun 2004 12:58:38 -0000 1.28.2.101
@@ -678,6 +678,12 @@
ERR_IF (sc.rate < 1) sc.rate = 1;
ERR_IF (sc.skip & ~1) sc.skip = !!sc.skip;
ERR_IF (sc.al_extents < 7) sc.al_extents = 127; // arbitrary minimum
+#define AL_MAX ((MD_AL_MAX_SIZE-1) * AL_EXTENTS_PT)
+ if(sc.al_extents > AL_MAX) {
+ ERR("sc.al_extents > "__stringify(AL_MAX));
+ sc.al_extents = AL_MAX;
+ }
+#undef AL_MAX
mdev->sync_conf.rate = sc.rate;
mdev->sync_conf.use_csums = sc.use_csums;
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/drbd/drbd_int.h,v
retrieving revision 1.58.2.168
retrieving revision 1.58.2.169
diff -u -3 -r1.58.2.168 -r1.58.2.169
--- drbd_int.h 1 Jun 2004 14:29:07 -0000 1.58.2.168
+++ drbd_int.h 7 Jun 2004 12:58:38 -0000 1.58.2.169
@@ -614,6 +614,7 @@
};
// activity log
+#define AL_EXTENTS_PT 61 // Extents per 512B sector (AKA transaction)
#define AL_EXTENT_SIZE_B 22 // One extent represents 4M Storage
#define AL_EXTENT_SIZE (1<<AL_EXTENT_SIZE_B)
// resync bitmap