INN commit: branches/2.6 (2 files)

INN Commit rra at isc.org
Sun Jan 7 14:43:33 UTC 2018


    Date: Sunday, January 7, 2018 @ 06:43:33
  Author: iulius
Revision: 10220

Adjust buffindexed header page size to platform

Previously, if the platform page size was larger than 16KB,
buffindexed would just refuse to work on that platform.  Instead,
increase the header page size to match the platform page size on
those platforms, but still require that the header page size be
a multiple of the platform page size.

Use sysconf(_SC_PAGESIZE) to get the page size instead of
getpagesize(), since it's the POSIX-standard way of doing this.

Backport patch against CURRENT from Russ Allbery.

Modified:
  branches/2.6/doc/pod/news.pod
  branches/2.6/storage/buffindexed/buffindexed.c

-----------------------------------+
 doc/pod/news.pod                  |    5 +++++
 storage/buffindexed/buffindexed.c |   22 ++++++++++++++++------
 2 files changed, 21 insertions(+), 6 deletions(-)

Modified: doc/pod/news.pod
===================================================================
--- doc/pod/news.pod	2018-01-07 14:39:53 UTC (rev 10219)
+++ doc/pod/news.pod	2018-01-07 14:43:33 UTC (rev 10220)
@@ -50,6 +50,11 @@
 
 =item *
 
+The buffindexed overview method will now hopefully work properly on
+systems with a native page size larger than 16KB.
+
+=item *
+
 Other minor bug fixes and documentation improvements.
 
 =back

Modified: storage/buffindexed/buffindexed.c
===================================================================
--- storage/buffindexed/buffindexed.c	2018-01-07 14:39:53 UTC (rev 10219)
+++ storage/buffindexed/buffindexed.c	2018-01-07 14:43:33 UTC (rev 10220)
@@ -66,7 +66,13 @@
 
 #define	OVMAXCYCBUFFNAME	8
 
-#define OV_HDR_PAGESIZE 16384
+/*
+** Default and minimum size of the header.  If the system default page size is
+** larger than this, we'll use the system page size instead.  The page size in
+** use is stored in the global hdr_pagesize variable.
+*/
+#define OV_HDR_MIN_PAGESIZE 16384
+
 #define OV_BEFOREBITF   (1 * OV_BLOCKSIZE)
 #define	OV_BLOCKSIZE	8192
 #define	OV_FUDGE	1024
@@ -252,6 +258,7 @@
 #define	_PATH_OVBUFFCONFIG	"buffindexed.conf"
 
 static long		pagesize = 0;
+static long		hdr_pagesize = OV_HDR_MIN_PAGESIZE;
 static OVBUFF		*ovbufftab = NULL;
 static OVBUFF           *ovbuffnext = NULL;
 static int              GROUPfd;
@@ -363,7 +370,7 @@
   ** external header occupies ... then round up to the next block.
   */
   base = len / (OV_BLOCKSIZE * 8) + OV_BEFOREBITF;
-  tonextblock = OV_HDR_PAGESIZE - (base & (OV_HDR_PAGESIZE - 1));
+  tonextblock = hdr_pagesize - (base & (hdr_pagesize - 1));
   ovbuff->base = base + tonextblock;
   if (S_ISREG(sb.st_mode) && (len != sb.st_size || ovbuff->base > sb.st_size)) {
     if (len != sb.st_size)
@@ -992,14 +999,17 @@
   }
   ovbuffmode = mode;
   if (pagesize == 0) {
-    pagesize = getpagesize();
+    pagesize = sysconf(_SC_PAGESIZE);
     if (pagesize == -1) {
-      syswarn("buffindexed: getpagesize failed");
+      syswarn("buffindexed: sysconf(_SC_PAGESIZE) failed");
       pagesize = 0;
       return false;
     }
-    if ((pagesize > OV_HDR_PAGESIZE) || (OV_HDR_PAGESIZE % pagesize)) {
-      warn("buffindexed: OV_HDR_PAGESIZE (%d) is not a multiple of pagesize (%ld)", OV_HDR_PAGESIZE, pagesize);
+    if (pagesize > OV_HDR_MIN_PAGESIZE)
+      hdr_pagesize = pagesize;
+    if ((hdr_pagesize % pagesize) != 0) {
+      warn("buffindexed: hdr_pagesize (%ld) is not a multiple of pagesize"
+           " (%ld)", hdr_pagesize, pagesize);
       return false;
     }
   }



More information about the inn-committers mailing list