#include "storage/checksum_impl.h"
-static int64 files = 0;
-static int64 blocks = 0;
+static int64 files_scanned = 0;
+static int64 files_written = 0;
+static int64 blocks_scanned = 0;
+static int64 blocks_written = 0;
static int64 badblocks = 0;
static ControlFileData *ControlFile;
int f;
BlockNumber blockno;
int flags;
+ int64 blocks_written_in_file = 0;
Assert(mode == PG_MODE_ENABLE ||
mode == PG_MODE_CHECK);
exit(1);
}
- files++;
+ files_scanned++;
for (blockno = 0;; blockno++)
{
blockno, fn, r, BLCKSZ);
exit(1);
}
- blocks++;
+ blocks_scanned++;
/*
* Since the file size is counted as total_size for progress status
{
int w;
+ /*
+ * Do not rewrite if the checksum is already set to the expected
+ * value.
+ */
+ if (header->pd_checksum == csum)
+ continue;
+
+ blocks_written_in_file++;
+
/* Set checksum in page header */
header->pd_checksum = csum;
pg_log_info("checksums enabled in file \"%s\"", fn);
}
+ /* Update write counters if any write activity has happened */
+ if (blocks_written_in_file > 0)
+ {
+ files_written++;
+ blocks_written += blocks_written_in_file;
+ }
+
close(f);
}
progress_report(true);
printf(_("Checksum operation completed\n"));
- printf(_("Files scanned: %s\n"), psprintf(INT64_FORMAT, files));
- printf(_("Blocks scanned: %s\n"), psprintf(INT64_FORMAT, blocks));
+ printf(_("Files scanned: %s\n"), psprintf(INT64_FORMAT, files_scanned));
+ printf(_("Blocks scanned: %s\n"), psprintf(INT64_FORMAT, blocks_scanned));
if (mode == PG_MODE_CHECK)
{
printf(_("Bad checksums: %s\n"), psprintf(INT64_FORMAT, badblocks));
if (badblocks > 0)
exit(1);
}
+ else if (mode == PG_MODE_ENABLE)
+ {
+ printf(_("Files written: %s\n"), psprintf(INT64_FORMAT, files_written));
+ printf(_("Blocks written: %s\n"), psprintf(INT64_FORMAT, blocks_written));
+ }
}
/*