Message ID | 20210128073708.25572-2-ddouwsma@redhat.com (mailing list archive) |
---|---|
State | Deferred, archived |
Headers | show |
Series | xfsprogs: xfs_logprint misc log decoding issues | expand |
On Thu, Jan 28, 2021 at 06:37:07PM +1100, Donald Douwsma wrote: > Logprint only dumps raw buffers for unhandled misc buffer types, but > this information is generally useful when debugging logprint issues so > allow it to print whenever -o is used. > > Switch to using the common xlog_print_data function to dump the buffer. > > Signed-off-by: Donald Douwsma <ddouwsma@redhat.com> > --- > logprint/log_misc.c | 19 +++---------------- > logprint/log_print_all.c | 2 +- > 2 files changed, 4 insertions(+), 17 deletions(-) > > diff --git a/logprint/log_misc.c b/logprint/log_misc.c > index c325f046..d44e9ff7 100644 > --- a/logprint/log_misc.c > +++ b/logprint/log_misc.c > @@ -392,23 +392,10 @@ xlog_print_trans_buffer(char **ptr, int len, int *i, int num_ops) > } > } else { > printf(_("BUF DATA\n")); > - if (print_data) { > - uint *dp = (uint *)*ptr; > - int nums = be32_to_cpu(head->oh_len) >> 2; > - int byte = 0; > - > - while (byte < nums) { > - if ((byte % 8) == 0) > - printf("%2x ", byte); > - printf("%8x ", *dp); > - dp++; > - byte++; > - if ((byte % 8) == 0) > - printf("\n"); > - } > - printf("\n"); > - } Nitpicking: One patch to collapse this into a xlog_recover_print_data call as a no-functional-changes cleanup, then a second patch to make the buffer dumps happen any time -D or -o are specified. TBH the sb/agheader decoders probably need some serious updating to handle newer fields. It's also unfortunate that xfs_db doesn't know how to decode log buffers; adding such a thing would be a neat way to enable targetted fuzzing of log recovery. --D > } > + > + xlog_recover_print_data(*ptr, be32_to_cpu(head->oh_len)); > + > *ptr += be32_to_cpu(head->oh_len); > } > if (head && head->oh_flags & XLOG_CONTINUE_TRANS) > diff --git a/logprint/log_print_all.c b/logprint/log_print_all.c > index eafffe28..2b9e810d 100644 > --- a/logprint/log_print_all.c > +++ b/logprint/log_print_all.c > @@ -176,8 +176,8 @@ xlog_recover_print_buffer( > } else { > printf(_(" BUF DATA\n")); > if (!print_buffer) continue; > - xlog_recover_print_data(p, len); > } > + xlog_recover_print_data(p, len); > } > } > > -- > 2.27.0 >
On 29/01/2021 04:35, Darrick J. Wong wrote: > On Thu, Jan 28, 2021 at 06:37:07PM +1100, Donald Douwsma wrote: >> Logprint only dumps raw buffers for unhandled misc buffer types, but >> this information is generally useful when debugging logprint issues so >> allow it to print whenever -o is used. >> >> Switch to using the common xlog_print_data function to dump the buffer. >> >> Signed-off-by: Donald Douwsma <ddouwsma@redhat.com> >> --- >> logprint/log_misc.c | 19 +++---------------- >> logprint/log_print_all.c | 2 +- >> 2 files changed, 4 insertions(+), 17 deletions(-) >> >> diff --git a/logprint/log_misc.c b/logprint/log_misc.c >> index c325f046..d44e9ff7 100644 >> --- a/logprint/log_misc.c >> +++ b/logprint/log_misc.c >> @@ -392,23 +392,10 @@ xlog_print_trans_buffer(char **ptr, int len, int *i, int num_ops) >> } >> } else { >> printf(_("BUF DATA\n")); >> - if (print_data) { >> - uint *dp = (uint *)*ptr; >> - int nums = be32_to_cpu(head->oh_len) >> 2; >> - int byte = 0; >> - >> - while (byte < nums) { >> - if ((byte % 8) == 0) >> - printf("%2x ", byte); >> - printf("%8x ", *dp); >> - dp++; >> - byte++; >> - if ((byte % 8) == 0) >> - printf("\n"); >> - } >> - printf("\n"); >> - } > > Nitpicking: One patch to collapse this into a xlog_recover_print_data > call as a no-functional-changes cleanup, then a second patch to make the > buffer dumps happen any time -D or -o are specified. > ok > TBH the sb/agheader decoders probably need some serious updating to > handle newer fields. It's also unfortunate that xfs_db doesn't know how > to decode log buffers; adding such a thing would be a neat way to enable > targetted fuzzing of log recovery. > The free space accounting probably isn't the most useful thing to be dumping because of the way they're re-calculated from the AG headers during recovery, but I'd been looking into a sb free space issue and this was confusing me. It could dump all the fields like xfs_db does, but that would be very verbose. By decode log buffers do you mean more of the raw log buffer? > --D > >> } >> + >> + xlog_recover_print_data(*ptr, be32_to_cpu(head->oh_len)); >> + >> *ptr += be32_to_cpu(head->oh_len); >> } >> if (head && head->oh_flags & XLOG_CONTINUE_TRANS) >> diff --git a/logprint/log_print_all.c b/logprint/log_print_all.c >> index eafffe28..2b9e810d 100644 >> --- a/logprint/log_print_all.c >> +++ b/logprint/log_print_all.c >> @@ -176,8 +176,8 @@ xlog_recover_print_buffer( >> } else { >> printf(_(" BUF DATA\n")); >> if (!print_buffer) continue; >> - xlog_recover_print_data(p, len); >> } >> + xlog_recover_print_data(p, len); >> } >> } >> >> -- >> 2.27.0 >> >
diff --git a/logprint/log_misc.c b/logprint/log_misc.c index c325f046..d44e9ff7 100644 --- a/logprint/log_misc.c +++ b/logprint/log_misc.c @@ -392,23 +392,10 @@ xlog_print_trans_buffer(char **ptr, int len, int *i, int num_ops) } } else { printf(_("BUF DATA\n")); - if (print_data) { - uint *dp = (uint *)*ptr; - int nums = be32_to_cpu(head->oh_len) >> 2; - int byte = 0; - - while (byte < nums) { - if ((byte % 8) == 0) - printf("%2x ", byte); - printf("%8x ", *dp); - dp++; - byte++; - if ((byte % 8) == 0) - printf("\n"); - } - printf("\n"); - } } + + xlog_recover_print_data(*ptr, be32_to_cpu(head->oh_len)); + *ptr += be32_to_cpu(head->oh_len); } if (head && head->oh_flags & XLOG_CONTINUE_TRANS) diff --git a/logprint/log_print_all.c b/logprint/log_print_all.c index eafffe28..2b9e810d 100644 --- a/logprint/log_print_all.c +++ b/logprint/log_print_all.c @@ -176,8 +176,8 @@ xlog_recover_print_buffer( } else { printf(_(" BUF DATA\n")); if (!print_buffer) continue; - xlog_recover_print_data(p, len); } + xlog_recover_print_data(p, len); } }
Logprint only dumps raw buffers for unhandled misc buffer types, but this information is generally useful when debugging logprint issues so allow it to print whenever -o is used. Switch to using the common xlog_print_data function to dump the buffer. Signed-off-by: Donald Douwsma <ddouwsma@redhat.com> --- logprint/log_misc.c | 19 +++---------------- logprint/log_print_all.c | 2 +- 2 files changed, 4 insertions(+), 17 deletions(-)