mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
pvck: dump show most recent metadata
This commit is contained in:
parent
9cf08836ef
commit
d051e899a5
24
tools/pvck.c
24
tools/pvck.c
@ -255,14 +255,18 @@ static int _dump_all_text(struct cmd_context *cmd, struct settings *set, const c
|
||||
char vgname[NAME_LEN+1];
|
||||
char id_str[ID_STR_SIZE];
|
||||
char id_first[ID_STR_SIZE];
|
||||
char latest_vgname[NAME_LEN+1];
|
||||
char latest_id_str[ID_STR_SIZE];
|
||||
char *text_buf;
|
||||
char *p;
|
||||
uint32_t buf_off; /* offset with buf which begins with mda_header */
|
||||
uint32_t buf_off_first = 0;
|
||||
uint32_t seqno;
|
||||
uint32_t latest_seqno;
|
||||
uint32_t crc;
|
||||
uint64_t text_size;
|
||||
uint64_t meta_size;
|
||||
uint64_t latest_offset;
|
||||
int metadata_offset_found = 0;
|
||||
int multiple_vgs = 0;
|
||||
int bad_end;
|
||||
@ -277,6 +281,11 @@ static int _dump_all_text(struct cmd_context *cmd, struct settings *set, const c
|
||||
}
|
||||
}
|
||||
|
||||
memset(latest_vgname, 0, sizeof(latest_vgname));
|
||||
memset(latest_id_str, 0, sizeof(latest_id_str));
|
||||
latest_offset = 0;
|
||||
latest_seqno = 0;
|
||||
|
||||
/*
|
||||
* If metadata has not wrapped, and the metadata area beginning
|
||||
* has not been damaged, the text area will begin with vgname {.
|
||||
@ -419,6 +428,13 @@ static int _dump_all_text(struct cmd_context *cmd, struct settings *set, const c
|
||||
(unsigned long long)text_size,
|
||||
crc, vgname, seqno, id_str);
|
||||
|
||||
if (!latest_seqno || (seqno > latest_seqno)) {
|
||||
latest_seqno = seqno;
|
||||
latest_offset = mda_offset + buf_off;
|
||||
memcpy(latest_vgname, vgname, NAME_LEN);
|
||||
memcpy(latest_id_str, id_str, ID_STR_SIZE);
|
||||
}
|
||||
|
||||
/*
|
||||
* save the location of the first metadata we've found so
|
||||
* we know where to stop after wrapping buf.
|
||||
@ -442,7 +458,7 @@ static int _dump_all_text(struct cmd_context *cmd, struct settings *set, const c
|
||||
_copy_line(str1, line, &len);
|
||||
log_print("%s", line);
|
||||
}
|
||||
if ((str2 = strstr(str1, "creation_time = "))) {
|
||||
if (str1 && (str2 = strstr(str1, "creation_time = "))) {
|
||||
memset(line, 0, sizeof(line));
|
||||
_copy_line(str2, line, &len);
|
||||
log_print("%s\n", line);
|
||||
@ -469,6 +485,12 @@ static int _dump_all_text(struct cmd_context *cmd, struct settings *set, const c
|
||||
if (multiple_vgs)
|
||||
log_warn("WARNING: metadata from multiple VGs was found.");
|
||||
|
||||
if (!set->metadata_offset_set)
|
||||
log_print("Most recent metadata found at %llu seqno %u for vg %s id %s",
|
||||
(unsigned long long)latest_offset, latest_seqno,
|
||||
latest_vgname, latest_id_str);
|
||||
|
||||
|
||||
if (fp) {
|
||||
if (fflush(fp))
|
||||
stack;
|
||||
|
Loading…
Reference in New Issue
Block a user