Revision: 14300
Author: adrian.chadd
Date: Mon Sep 14 22:42:21 2009
Log: Some more random tidyups:

* modify the debug section to be section 86
* log the command parameters at debug level 2
* fix the fread error log entry to not log if its just EOF


http://code.google.com/p/lusca-cache/source/detail?r=14300

Modified:
  /branches/LUSCA_HEAD/app/ufs_rebuild/ufs_build_dir.c
  /branches/LUSCA_HEAD/app/ufs_rebuild/ufs_build_log.c
  /branches/LUSCA_HEAD/app/ufs_rebuild/ufs_rebuild.c

=======================================
--- /branches/LUSCA_HEAD/app/ufs_rebuild/ufs_build_dir.c        Fri Aug 21  
20:23:30 2009
+++ /branches/LUSCA_HEAD/app/ufs_rebuild/ufs_build_dir.c        Mon Sep 14  
22:42:21 2009
@@ -62,7 +62,7 @@
        int len;
        struct stat sb;

-       debug(47, 3) ("read_file: %s\n", path);
+       debug(86, 3) ("read_file: %s\n", path);
        fd = open(path, O_RDONLY);
        if (fd < 0) {
                perror("open");
@@ -83,7 +83,7 @@
        }

        len = read(fd, buf, BUFSIZE);
-       debug(47, 3) ("read_file: FILE: %s\n", path);
+       debug(86, 3) ("read_file: FILE: %s\n", path);

        if (! parse_header(buf, len, re)) {
                close(fd);
@@ -119,7 +119,7 @@
                                return;

                        getCurrentTime();
-                       debug(47, 2) ("read_dir: opening dir %s\n", dir);
+                       debug(86, 2) ("read_dir: opening dir %s\n", dir);
                        d = opendir(dir);
                        if (! d) {
                                perror("opendir");
@@ -132,23 +132,23 @@

                                /* Verify that the given filename belongs in 
the given directory */
                                if (sscanf(de->d_name, "%x", &fn) != 1) {
-                                       debug(47, 1) ("read_dir: invalid %s\n", 
de->d_name);
+                                       debug(86, 1) ("read_dir: invalid %s\n", 
de->d_name);
                                                continue;
                                }
                                if (! store_ufs_filenum_correct_dir(sd, fn, i, 
j)) {
-                                       debug(47, 1) ("read_dir: %s does not 
belong in %d/%d\n", de->d_name,  
i, j);
+                                       debug(86, 1) ("read_dir: %s does not 
belong in %d/%d\n", de->d_name,  
i, j);
                                                continue;
                                }

                                snprintf(path, sizeof(path) - 1, "%s/%s", dir, 
de->d_name);
-                               debug(47, 3) ("read_dir: opening %s\n", path);
+                               debug(86, 3) ("read_dir: opening %s\n", path);

                                rebuild_entry_init(&re);
                                /* Only write out the swap entry if the file 
metadata was correctly  
read */
                                if (read_file(path, &re)) {
                                        re.swap_filen = fn;
                                        if (! write_swaplog_entry(stdout, &re)) 
{
-                                               debug(47, 1) ("read_dir: 
write() failed: (%d) %s\n", errno,  
xstrerror());
+                                               debug(86, 1) ("read_dir: 
write() failed: (%d) %s\n", errno,  
xstrerror());
                                                rebuild_entry_done(&re);
                                                return;
                                        }
=======================================
--- /branches/LUSCA_HEAD/app/ufs_rebuild/ufs_build_log.c        Thu Jul 23  
03:01:04 2009
+++ /branches/LUSCA_HEAD/app/ufs_rebuild/ufs_build_log.c        Mon Sep 14  
22:42:21 2009
@@ -71,9 +71,12 @@
        char buf[128];
        storeSwapLogData sd;

+
        r = fread(buf, rebuild_entry_size(version), 1, fp);
        if (r != 1) {
-               debug(1, 2) ("fread: returned %d (ferror %d)\n", r, ferror(fp));
+               if (feof(fp))
+                       return 0;
+               debug(86, 2) ("fread: returned %d (ferror %d)\n", r, 
ferror(fp));
                return 0;
        }
        num_objects++;
@@ -94,11 +97,11 @@
        if (sd.op == SWAP_LOG_ADD || sd.op == SWAP_LOG_DEL) {
                num_valid_objects++;
                if (fwrite(&sd, sizeof(sd), 1, stdout) != 1) {
-                       debug(47, 1) ("write failed: (%d) %s\n", errno, 
xstrerror());
+                       debug(86, 1) ("write failed: (%d) %s\n", errno, 
xstrerror());
                        return 0;
                }
        } else {
-               debug(1, 5) ("error! Got swaplog entry op %d?!\n", sd.op);
+               debug(86, 5) ("error! Got swaplog entry op %d?!\n", sd.op);
                num_invalid_objects++;
        }

@@ -151,7 +154,7 @@
                } else if (hdr.version == 1 && hdr.record_size ==  
sizeof(storeSwapLogDataOld)) {
                        version = 0;
                } else {
-                       debug(1, 1) ("Unsupported swap.state version %d size 
%d\n",  
hdr.version, hdr.record_size);
+                       debug(86, 1) ("Unsupported swap.state version %d size 
%d\n",  
hdr.version, hdr.record_size);
                        fclose(fp);
                        return;
                }
@@ -197,7 +200,7 @@

      read_log_file(argv[2]);

-    debug(1, 1) ("%s: Read %d objects\n", argv[2], num_objects);
+    debug(86, 1) ("%s: Read %d objects\n", argv[2], num_objects);

      return 0;
  }
=======================================
--- /branches/LUSCA_HEAD/app/ufs_rebuild/ufs_rebuild.c  Mon Sep 14 18:39:09  
2009
+++ /branches/LUSCA_HEAD/app/ufs_rebuild/ufs_rebuild.c  Mon Sep 14 22:42:21  
2009
@@ -9,6 +9,7 @@

  #include "libcore/varargs.h"
  #include "libcore/kb.h"
+#include "libcore/tools.h"
  #include "libsqdebug/debug.h"
  #include "libsqstore/store_mgr.h"
  #include "libsqstore/store_log.h"
@@ -69,6 +70,9 @@
                debug_args = xstrdup(t);
        _db_init(debug_args);
        _db_set_stderr_debug(99);
+       getCurrentTime();
+
+       debug(86, 2) ("ufs_rebuild: cmd=%s, dir=%s, l1=%d, l2=%d, 
swaplog=%s\n",  
argv[1], argv[2], atoi(argv[3]), atoi(argv[4]), argv[5]);

        store_ufs_init(&store_ufs_info, argv[2], atoi(argv[3]), atoi(argv[4]),  
argv[5]);


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"lusca-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/lusca-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to