linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: linux-ext4@vger.kernel.org
Cc: aneesh.kumar@linux.vnet.ibm.com
Subject: [PATCH 4/4] Add ext4replay tool.
Date: Fri,  4 May 2007 14:43:24 +0530	[thread overview]
Message-ID: <11782700142251-git-send-email-aneesh.kumar@linux.vnet.ibm.com> (raw)
Message-ID: <69f2894044fa7c5ad14a59c22e603bc5529dce2a.1178262586.git.aneesh.kumar@linux.vnet.ibm.com> (raw)
In-Reply-To: <11782700113984-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
In-Reply-To: <eb16ba5f2c6f399ea747169097434ae84443728f.1178262585.git.aneesh.kumar@linux.vnet.ibm.com>

From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

This tool can be used to replay the transactions stored in the database
during ext4migrate.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 ext4migrate/Makefile.in |    7 ++++++-
 ext4migrate/replay.c    |   45 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 1 deletions(-)
 create mode 100644 ext4migrate/replay.c

diff --git a/ext4migrate/Makefile.in b/ext4migrate/Makefile.in
index b000ae7..8fe6291 100644
--- a/ext4migrate/Makefile.in
+++ b/ext4migrate/Makefile.in
@@ -21,7 +21,7 @@ DEPLIBS= $(LIBEXT2FS)  $(LIBCOM_ERR)
 	@#cc -g -I../lib/  -Wunreachable-code -Wunused -Wunused-function
 	@#-Wunused-label  -Wunused-parameter -Wunused-value  -Wunused-variable  -c migrate.c
 
-PROGS= ext4migrate
+PROGS= ext4migrate ext4replay
 
 all:: $(PROGS)
 
@@ -29,6 +29,10 @@ ext4migrate: migrate.o  extents.o $(DEPLIBS)
 	@echo "	LD $@"
 	@$(CC) $(ALL_LDFLAGS) -o ext4migrate migrate.o extents.o $(LIBS)
 
+ext4replay: replay.o
+	@echo "	LD $@"
+	@$(CC) $(ALL_LDFLAGS) -o ext4replay replay.o  -ltdb
+
 installdirs:
 	@echo "	MKINSTALLDIRS $(root_sbindir)"
 	@$(MKINSTALLDIRS) $(DESTDIR)$(root_sbindir)
@@ -64,3 +68,4 @@ distclean: clean
 #
 migrate.o: $(srcdir)/migrate.c
 extents.o: $(srcdir)/extents.c
+replay.o:  $(srcdir)/replay.c
diff --git a/ext4migrate/replay.c b/ext4migrate/replay.c
new file mode 100644
index 0000000..8476416
--- /dev/null
+++ b/ext4migrate/replay.c
@@ -0,0 +1,45 @@
+#include <stdio.h>
+#include <tdb.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+
+void usage(char *prg_name)
+{
+	fprintf(stderr, "Usage: %s <transaction file> <filesystem>\n", prg_name);
+	exit(1);
+
+}
+
+
+main(int argc, char *argv[])
+{
+	TDB_CONTEXT *tdb;
+	TDB_DATA key, data;
+	long long int location;
+	int fd;
+
+	if (argc != 3)
+		usage(argv[0]);
+
+	tdb = tdb_open(argv[1], 0, 0, O_RDONLY, 0600);
+
+	if (!tdb) {
+		printf("Failed tdb_open %s\n",  strerror(errno));
+		exit(1);
+	}
+
+	fd = open(argv[2], O_WRONLY);
+
+	for (key = tdb_firstkey(tdb); key.dptr; key = tdb_nextkey(tdb, key)) {
+		data = tdb_fetch(tdb, key);
+		location = *(long long int *)key.dptr;
+		printf("Replayed transaction of size %d at location %lld\n", data.dsize, location);
+		lseek(fd, location, SEEK_SET);
+		write(fd, data.dptr, data.dsize);
+	}
+	close(fd);
+	tdb_close(tdb);
+
+}
-- 
1.5.2.rc0.71.g4342-dirty

  parent reply	other threads:[~2007-05-04  9:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-04  9:13 [RFC][take 4] e2fsprogs: Add ext4migrate Aneesh Kumar K.V
2007-05-06  5:17 ` Andreas Dilger
2007-05-07  3:26   ` Aneesh Kumar K.V
2007-05-07 13:20     ` Theodore Tso
2007-05-07 13:46       ` Aneesh Kumar K.V
2007-05-07 15:57         ` Theodore Tso
2007-05-07 21:01         ` Andreas Dilger
2007-05-07 13:59       ` Aneesh Kumar K.V
     [not found] ` <eb16ba5f2c6f399ea747169097434ae84443728f.1178262585.git.aneesh.kumar@linux.vnet.ibm.com>
2007-05-04  9:13   ` [PATCH 1/4] Add unix COW io manager Aneesh Kumar K.V
     [not found]   ` <344eabfd05e36374043e8cd0b4e166a66f88bec6.1178262586.git.aneesh.kumar@linux.vnet.ibm.com>
2007-05-04  9:13     ` [PATCH 2/4] Add extent related functions Aneesh Kumar K.V
     [not found]   ` <1dcc9dea2106570ec314b59bf69e7e3720818a94.1178262586.git.aneesh.kumar@linux.vnet.ibm.com>
2007-05-04  9:13     ` [PATCH 3/4] e2fsprogs: Add ext4migrate Aneesh Kumar K.V
     [not found]   ` <69f2894044fa7c5ad14a59c22e603bc5529dce2a.1178262586.git.aneesh.kumar@linux.vnet.ibm.com>
2007-05-04  9:13     ` Aneesh Kumar K.V [this message]
2007-05-07 13:01   ` [PATCH 1/4] Add unix COW io manager Theodore Tso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11782700142251-git-send-email-aneesh.kumar@linux.vnet.ibm.com \
    --to=aneesh.kumar@linux.vnet.ibm.com \
    --cc=linux-ext4@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).