]> arthur.barton.de Git - netatalk.git/commitdiff
Remove txn grouping
authorFrank Lahm <franklahm@googlemail.com>
Tue, 19 Apr 2011 13:46:43 +0000 (15:46 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Tue, 19 Apr 2011 13:46:43 +0000 (15:46 +0200)
etc/cnid_dbd/cmd_dbd.c
etc/cnid_dbd/cmd_dbd_scanvol.c
etc/cnid_dbd/db_param.h
etc/cnid_dbd/dbif.c

index 969577a5887536c9c9d422903d6453ac861d416d..d9d5de7977b551d7bd8960ece7db2d1a3bdda534 100644 (file)
@@ -92,7 +92,6 @@ static struct db_param db_param = {
     64 * 1024,                  /* bdb cachesize (64 MB) */
     0,                          /* flush_interval */
     0,                          /* flush_frequency */
-    1000,                       /* txn_frequency */
     0,                          /* usock_file */
     -1,                         /* fd_table_size */
     -1,                         /* idle_timeout */
index 5b723fe381ea1070476ff9f27a2cb23c3558bcec..fe58d8aae48467e43001dd753523d8dcb85b355a 100644 (file)
@@ -971,7 +971,7 @@ static int dbd_readdir(int volroot, cnid_t did)
             cnid = check_cnid(ep->d_name, did, &st, adfile_ok, adflags);
 
             /* Now add this object to our rebuild dbd */
-            if (cnid) {
+            if (cnid && dbd_rebuild) {
                 static uint count = 0;
                 rqst.cnid = rply.cnid;
                 ret = dbd_rebuild_add(dbd_rebuild, &rqst, &rply);
@@ -1019,7 +1019,7 @@ static int dbd_readdir(int volroot, cnid_t did)
             close(cwd);
             *(strrchr(cwdbuf, '/')) = 0;
             if (ret < 0)
-                continue;
+                return -1;
         }
     }
 
@@ -1074,8 +1074,6 @@ static void delete_orphaned_cnids(DBD *dbd, DBD *dbd_rebuild, dbd_flags_t flags)
     struct cnid_dbd_rqst rqst;
     struct cnid_dbd_rply rply;
 
-    dbd->db_param.txn_frequency = 0;
-
     /* jump over rootinfo key */
     if ( dbif_idwalk(dbd, &dbd_cnid, 0) != 1)
         return;
@@ -1177,7 +1175,6 @@ int cmd_dbd_scanvol(DBD *dbd_ref, struct volinfo *volinfo, dbd_flags_t flags)
 
     /* Set cachesize for in-memory rebuild db */
     db_param.cachesize = 64 * 1024;         /* 64 MB */
-    db_param.txn_frequency = 1000;          /* close txn every 1000 objects */
     db_param.logfile_autoremove = 1;
 
     /* Make it accessible for all funcs */
@@ -1189,7 +1186,8 @@ int cmd_dbd_scanvol(DBD *dbd_ref, struct volinfo *volinfo, dbd_flags_t flags)
         return -1;
     }
 
-    if (! nocniddb) {
+    /* temporary rebuild db, used with -re rebuild to delete unused CNIDs, not used with -f */
+    if (! nocniddb && !(flags & DBD_FLAGS_FORCE)) {
         /* Get volume stamp */
         dbd_getstamp(dbd, &rqst, &rply);
         if (rply.result != CNID_DBD_RES_OK)
@@ -1223,7 +1221,7 @@ int cmd_dbd_scanvol(DBD *dbd_ref, struct volinfo *volinfo, dbd_flags_t flags)
 
     if (setjmp(jmp) != 0) {
         ret = 0;                /* Got signal, jump from dbd_readdir */
-        goto exit_cleanup;              
+        goto exit;
     }
 
     /* scanvol */
@@ -1232,17 +1230,17 @@ int cmd_dbd_scanvol(DBD *dbd_ref, struct volinfo *volinfo, dbd_flags_t flags)
         goto exit;
     }
 
-exit_cleanup:
+exit:
     if (! nocniddb) {
-        dbif_txn_close(dbd, 2);
-        dbif_txn_close(dbd_rebuild, 2);
+        dbif_txn_close(dbd, 1);
+        if (dbd_rebuild)
+            dbif_txn_close(dbd_rebuild, 1);
         if ((flags & DBD_FLAGS_EXCL) && !(flags & DBD_FLAGS_FORCE))
             /* We can only do this in exclusive mode, otherwise we might delete CNIDs added from
                other clients in between our pass 1 and 2 */
             delete_orphaned_cnids(dbd, dbd_rebuild, flags);
     }
 
-exit:
     if (dbd_rebuild) {
         dbd_log(LOGDEBUG, "Closing tmp db");
         dbif_close(dbd_rebuild);
index f1b188c18576fb968abbabd9e719a396cec27196..ebcea6b823185494b937d31a78df6a0974e36a10 100644 (file)
@@ -22,7 +22,6 @@ struct db_param {
     int cachesize;              /* in KB */
     int flush_interval;
     int flush_frequency;
-    int txn_frequency;
     char usock_file[MAXPATHLEN + 1];    
     int fd_table_size;
     int idle_timeout;
index 1825145b0b17f744d835072b4efcf7cdf191a767..be9b568fe2dc076391f091fa355b779df61ae93c 100644 (file)
@@ -791,15 +791,9 @@ int dbif_txn_abort(DBD *dbd)
 }
 
 /* 
-   ret = 2 -> commit txn regardless of db_param.txn_frequency
    ret = 1 -> commit txn if db_param.txn_frequency
    ret = 0 -> abort txn db_param.txn_frequency -> exit!
    anything else -> exit!
-
-   db_param of the db environment might specify txn_frequency > 1 in which case
-   we only close a txn every txn_frequency time. the `dbd` command uses this for the
-   temp rebuild db, cnid_dbd keeps it at 0. For increasing cnid_dbd throughput this
-   should be tuned and testes as well.
 */
 void dbif_txn_close(DBD *dbd, int ret)
 {
@@ -809,12 +803,6 @@ void dbif_txn_close(DBD *dbd, int ret)
             exit(EXIT_FAILURE);
         }
     } else if (ret == 1 || ret == 2) {
-        static uint count;
-        if (ret != 2 && dbd->db_param.txn_frequency > 1) {
-            count++;
-            if ((count % dbd->db_param.txn_frequency) != 0)
-                return;
-        }
         ret = dbif_txn_commit(dbd);
         if (  ret < 0) {
             LOG( log_error, logtype_cnid, "Fatal error committing transaction. Exiting!");