Project

General

Profile

Actions

Submit #1497

closed

HAMMER Util - add `mirror-dump header' to retrieve header information from the stream

Added by qhwt+dfly about 12 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Userland
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:

Description

HAMMER Util - add `mirror-dump header' to retrieve header information from the stream

This may be useful when you want to archive PFSes on a HAMMER filesystem
to a non-hammer storage, format the original or a new hard drive, then
restore the PFSes back on, realizing you forgot writing down the shared-uuid's
(OK you probably won't, but I did :) The output is similar to that of
`hammer pfs-status' command applied to a live PFS, without `PFS #n' line
and the corresponding curly-brace.

---
sbin/hammer/cmd_mirror.c | 15 +++++++++++--
sbin/hammer/cmd_pseudofs.c | 2 --
sbin/hammer/hammer.8 | 5 +++-
sbin/hammer/hammer.c | 4 +
--
sbin/hammer/hammer.h | 4 +--
5 files changed, 21 insertions(
), 9 deletions(-)

diff --git a/sbin/hammer/cmd_mirror.c b/sbin/hammer/cmd_mirror.c
index a17fced..d463858 100644
--- a/sbin/hammer/cmd_mirror.c
+++ b/sbin/hammer/cmd_mirror.c
@ -717,7 +717,7 @ again:
}

void
-hammer_cmd_mirror_dump(void)
+hammer_cmd_mirror_dump(char **av, int ac) {
char *buf = malloc(SERIALBUF_SIZE);
struct hammer_ioc_mrecord_head pickup;
@ -726,6 +726,12 @ hammer_cmd_mirror_dump(void)
int size;
int offset;
int bytes;
+ int header_only = 0;

if (ac 1 && strcmp(*av, "header") 0)
+ header_only = 1;
+ else if (ac != 0)
+ mirror_usage(1);
/*
 * Read and process the PFS header 
@ -735,6 +741,11 @ hammer_cmd_mirror_dump(void)
mrec = read_mrecord(0, &error, &pickup);

+ if (header_only && mrec != NULL) {
+ dump_pfsd(&mrec->pfs.pfsd);
+ return;
+ }
+
/* * Read and process bulk records
*/
@ -1406,7 +1417,7 @ mirror_usage(int code)
"hammer mirror-read <filesystem> [begin-tid]\n"
"hammer mirror-read-stream <filesystem> [begin-tid]\n"
"hammer mirror-write <filesystem>\n"
- "hammer mirror-dump\n"
+ "hammer mirror-dump [header]\n"
"hammer mirror-copy [[user@]host:]<filesystem>"
" [[user@]host:]<filesystem>\n"
"hammer mirror-stream [[user@]host:]<filesystem>"
diff --git a/sbin/hammer/cmd_pseudofs.c b/sbin/hammer/cmd_pseudofs.c
index a987eff..db2beb7 100644
--- a/sbin/hammer/cmd_pseudofs.c
+++ b/sbin/hammer/cmd_pseudofs.c
@ -38,7 +38,6 @

static void parse_pfsd_options(char **av, int ac, hammer_pseudofs_data_t pfsd);
static void init_pfsd(hammer_pseudofs_data_t pfsd, int is_slave);
static void dump_pfsd(hammer_pseudofs_data_t pfsd);
static void pseudofs_usage(int code);
static int getyn(void);
static int timetosecs(char *str);
@ -466,7 +465,6 @ init_pfsd(hammer_pseudofs_data_t pfsd, int is_slave)
pfsd
>mirror_flags |= HAMMER_PFSD_SLAVE;
}

-static
void
dump_pfsd(hammer_pseudofs_data_t pfsd) {
diff --git a/sbin/hammer/hammer.8 b/sbin/hammer/hammer.8
index 44f6bae..feadd6a 100644
--- a/sbin/hammer/hammer.8
++ b/sbin/hammer/hammer.8
@ -762,12 +762,15 @ configuration field for the two file systems do not match.
If the target PFS does not exist this command will ask you whether
you want to create a compatible PFS slave for the target or not.
.\" ==== mirror-dump ====
.It Ar mirror-dump
.It Ar mirror-dump Ar [header]
A
.Ar mirror-read
can be piped into a
.Ar mirror-dump
to dump an ASCII representation of the mirroring stream.
If the keyword
.Ar header
is specified, only the header information is shown.
.\" ==== mirror-copy ====
.It Ar mirror-copy Ar [[user@]host:]filesystem Ar [[user@]host:]filesystem
This is a shortcut which pipes a
diff --git a/sbin/hammer/hammer.c b/sbin/hammer/hammer.c
index 000bb99..637b302 100644
-- a/sbin/hammer/hammer.c
++ b/sbin/hammer/hammer.c
@ -352,7 +352,7 @ main(int ac, char **av)
else if (strcmp(av0, "mirror-stream") 0)
hammer_cmd_mirror_copy(av + 1, ac - 1, 1);
else if (strcmp(av[0], "mirror-dump") 0)
- hammer_cmd_mirror_dump();
+ hammer_cmd_mirror_dump(av + 1, ac - 1);
else
usage(1);
exit(0);
@ -482,7 +482,7 @ usage(int exit_code)
"hammer mirror-read <filesystem> [begin-tid]\n"
"hammer mirror-read-stream <filesystem> [begin-tid]\n"
"hammer mirror-write <filesystem>\n"
- "hammer mirror-dump\n"
+ "hammer mirror-dump [header]\n"
"hammer mirror-copy [[user@]host:]<filesystem>"
" [[user@]host:]<filesystem>\n"
"hammer mirror-stream [[user@]host:]<filesystem>"
diff --git a/sbin/hammer/hammer.h b/sbin/hammer/hammer.h
index b0c6bdd..59a9167 100644
--- a/sbin/hammer/hammer.h
+++ b/sbin/hammer/hammer.h
@ -86,7 +86,7 @ void hammer_cmd_synctid(char **av, int ac);
void hammer_cmd_mirror_read(char **av, int ac, int streaming);
void hammer_cmd_mirror_write(char **av, int ac);
void hammer_cmd_mirror_copy(char **av, int ac, int streaming);
-void hammer_cmd_mirror_dump(void);
+void hammer_cmd_mirror_dump(char **av, int ac);
void hammer_cmd_history(const char *offset_str, char **av, int ac);
void hammer_cmd_blockmap(void);
void hammer_cmd_reblock(char **av, int ac, int flags);
@ -111,4 +111,4 @ void hammer_reset_cycle(void);

int getpfs(struct hammer_ioc_pseudofs_rw *pfs, const char *path);
void relpfs(int fd, struct hammer_ioc_pseudofs_rw *pfs);

+void dump_pfsd(hammer_pseudofs_data_t pfsd);
-

1.6.4
Actions #1

Updated by tuxillo almost 8 years ago

  • Tracker changed from Bug to Submit
  • Description updated (diff)
  • Category set to Userland
  • Assignee changed from 0 to tuxillo
  • Target version set to 3.8

Matt,

Did you see this patch? Should we integrate it?

Cheers,
Antonio Huete

Actions #2

Updated by tuxillo over 7 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF