Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/nvi/dist/common Fix recovery mode, there were m...



details:   https://anonhg.NetBSD.org/src/rev/f01323184a04
branches:  trunk
changeset: 791754:f01323184a04
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Nov 30 14:54:29 2013 +0000

description:
Fix recovery mode, there were multiple issues:
1. the btree filename was not set so that we always used a transient
   in-memory db for the data
2. we did not call sync after creation with R_RECNOSYNC so that the header
   of the btree was never written
3. we did not call the right flavor of sync before copying the tree to the
   preserved files

diffstat:

 external/bsd/nvi/dist/common/recover.c |  12 ++++++++++--
 external/bsd/nvi/dist/common/vi_db1.c  |  23 +++++++++++++++++++----
 2 files changed, 29 insertions(+), 6 deletions(-)

diffs (66 lines):

diff -r 3c7dbf5b6968 -r f01323184a04 external/bsd/nvi/dist/common/recover.c
--- a/external/bsd/nvi/dist/common/recover.c    Sat Nov 30 14:52:40 2013 +0000
+++ b/external/bsd/nvi/dist/common/recover.c    Sat Nov 30 14:54:29 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: recover.c,v 1.3 2013/11/27 21:17:36 christos Exp $ */
+/*     $NetBSD: recover.c,v 1.4 2013/11/30 14:54:29 christos Exp $ */
 /*-
  * Copyright (c) 1993, 1994
  *     The Regents of the University of California.  All rights reserved.
@@ -260,7 +260,15 @@
 
        /* Sync the file if it's been modified. */
        if (F_ISSET(ep, F_MODIFIED)) {
-               if (ep->db->sync(ep->db, 0)) {
+               /*
+                * If we are using a db1 version of the database,
+                * we want to sync the underlying btree not the
+                * recno tree which is transient anyway.
+                */
+#ifndef R_RECNOSYNC
+#define        R_RECNOSYNC 0
+#endif
+               if (ep->db->sync(ep->db, R_RECNOSYNC)) {
                        F_CLR(ep, F_RCV_ON | F_RCV_NORM);
                        msgq_str(sp, M_SYSERR,
                            ep->rcv_path, "060|File backup failed: %s");
diff -r 3c7dbf5b6968 -r f01323184a04 external/bsd/nvi/dist/common/vi_db1.c
--- a/external/bsd/nvi/dist/common/vi_db1.c     Sat Nov 30 14:52:40 2013 +0000
+++ b/external/bsd/nvi/dist/common/vi_db1.c     Sat Nov 30 14:54:29 2013 +0000
@@ -685,10 +685,19 @@
 
        memset(&oinfo, 0, sizeof(RECNOINFO));
        oinfo.bval = '\n';                      /* Always set. */
-       oinfo.psize = psize;
-       oinfo.flags = R_SNAPSHOT;
-       if (rcv_name)
-               oinfo.bfname = ep->rcv_path;
+       /*
+        * If we are not recovering, set the pagesize and arrange to
+        * first get a snapshot of the file.
+        */
+       if (rcv_name == NULL) {
+               oinfo.psize = psize;
+               oinfo.flags = R_SNAPSHOT;
+       }
+       /*
+        * Always set the btree name, otherwise we are going to be using
+        * an in-memory database for the btree.
+        */
+       oinfo.bfname = ep->rcv_path;
 
 #define _DB_OPEN_MODE  S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH
 
@@ -709,6 +718,12 @@
 
                *open_err = 1;
                return 1;
+       } else {
+               /*
+                * We always sync the underlying btree so that the header
+                * is written first
+                */
+               ep->db->sync(ep->db, R_RECNOSYNC);
        }
 
        return 0;



Home | Main Index | Thread Index | Old Index