diff mbox

[v2,11/14] replay-log: output log replay offset in verbose mode

Message ID 1504104706-11965-12-git-send-email-amir73il@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Amir Goldstein Aug. 30, 2017, 2:51 p.m. UTC
This helps exporting the recorded log to an image file using dd.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 src/log-writes/log-writes.c | 8 +++++---
 src/log-writes/replay-log.c | 6 ++++--
 2 files changed, 9 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/src/log-writes/log-writes.c b/src/log-writes/log-writes.c
index fa4f3f3..ba66a5c 100644
--- a/src/log-writes/log-writes.c
+++ b/src/log-writes/log-writes.c
@@ -158,12 +158,14 @@  int log_replay_next_entry(struct log *log, struct log_write_entry *entry,
 		}
 	}
 
-	if (log_writes_verbose)
-		printf("replaying %d: sector %llu, size %llu, flags %llu\n",
-		       (int)log->cur_entry - 1,
+	if (log_writes_verbose) {
+		offset = lseek(log->logfd, 0, SEEK_CUR);
+		printf("replaying %d@%llu: sector %llu, size %llu, flags %llu\n",
+		       (int)log->cur_entry - 1, offset / log->sectorsize,
 		       (unsigned long long)le64_to_cpu(entry->sector),
 		       (unsigned long long)size,
 		       (unsigned long long)le64_to_cpu(entry->flags));
+	}
 	if (!size)
 		return 0;
 
diff --git a/src/log-writes/replay-log.c b/src/log-writes/replay-log.c
index 759c3c7..87c03a2 100644
--- a/src/log-writes/replay-log.c
+++ b/src/log-writes/replay-log.c
@@ -284,8 +284,10 @@  int main(int argc, char **argv)
 			num_entries++;
 			if ((run_limit && num_entries == run_limit) ||
 			    should_stop(entry, stop_flags, end_mark)) {
-				printf("%llu\n",
-				       (unsigned long long)log->cur_entry - 1);
+				off_t offset = lseek(log->logfd, 0, SEEK_CUR);
+
+				printf("%llu@%llu\n",
+				       (unsigned long long)log->cur_entry - 1, offset / log->sectorsize);
 				log_free(log);
 				return 0;
 			}