]> git.sur5r.net Git - openldap/commitdiff
mdb_stat -ff[f]: show contiguous page spans.
authorHallvard Furuseth <hallvard@openldap.org>
Sat, 16 Feb 2013 18:07:16 +0000 (19:07 +0100)
committerHallvard Furuseth <hallvard@openldap.org>
Sat, 16 Feb 2013 18:07:16 +0000 (19:07 +0100)
libraries/liblmdb/mdb_stat.1
libraries/liblmdb/mdb_stat.c

index 205fc88deea3adca620cf74529b3d5e4d5e6248d..1307c39d09fee383706ead72ba6b4f93766ac03f 100644 (file)
@@ -9,7 +9,7 @@ mdb_stat \- LMDB environment status tool
 [\c
 .BR \-e ]
 [\c
-.BR \-f [ f ]]
+.BR \-f [ f [ f ]]]
 [\c
 .BR \-n ]
 [\c
@@ -25,8 +25,9 @@ utility displays the status of an LMDB environment.
 Display information about the database environment.
 .TP
 .BR \-f
-Display information about the environment freelist. If \fB\-ff\fP is given,
-display the full list of page IDs in the freelist.
+Display information about the environment freelist.
+If \fB\-ff\fP is given, summarize each freelist entry.
+If \fB\-fff\fP is given, display the full list of page IDs in the freelist.
 .TP
 .BR \-n
 Display the status of an LMDB database which does not use subdirectories.
index 13a24f9cbdde5da2c08868eecef25fc80cb33a86..dd0735f24265588c729d8296b5360199cb5e6387 100644 (file)
@@ -1,6 +1,6 @@
 /* mdb_stat.c - memory-mapped database status tool */
 /*
- * Copyright 2011 Howard Chu, Symas Corp.
+ * Copyright 2011-2013 Howard Chu, Symas Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,7 @@ static void prstat(MDB_stat *ms)
 
 static void usage(char *prog)
 {
-       fprintf(stderr, "usage: %s dbpath [-e] [-f[f]] [-n] [-a|-s subdb]\n", prog);
+       fprintf(stderr, "usage: %s dbpath [-e] [-f[f[f]]] [-n] [-a|-s subdb]\n", prog);
        exit(EXIT_FAILURE);
 }
 
@@ -142,12 +142,28 @@ int main(int argc, char *argv[])
                        iptr = data.mv_data;
                        pages += *iptr;
                        if (freinfo > 1) {
-                               size_t i, j;
+                               char *bad = "";
+                               size_t pg, prev;
+                               ssize_t i, j, span = 0;
                                j = *iptr++;
-                               printf("    Transaction %zu, %zu pages\n",
-                                       *(size_t *)key.mv_data, j);
-                               for (i=0; i<j; i++)
-                                       printf("      %zu\n", iptr[i]);
+                               for (i = j, prev = 1; --i >= 0; ) {
+                                       pg = iptr[i];
+                                       if (pg <= prev)
+                                               bad = " [bad sequence]";
+                                       prev = pg;
+                                       pg += span;
+                                       for (; i >= span && iptr[i-span] == pg; span++, pg++) ;
+                               }
+                               printf("    Transaction %zu, %zd pages, maxspan %zd%s\n",
+                                       *(size_t *)key.mv_data, j, span, bad);
+                               if (freinfo > 2) {
+                                       for (--j; j >= 0; ) {
+                                               pg = iptr[j];
+                                               for (span=1; --j >= 0 && iptr[j] == pg+span; span++) ;
+                                               printf(span>1 ? "     %9zu[%zd]\n" : "     %9zu\n",
+                                                       pg, span);
+                                       }
+                               }
                        }
                }
                mdb_cursor_close(cursor);