2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * Copyright (c) 2016 Oracle, Inc.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it would be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 /* Extent Free Items */
30 struct xfs_efi_log_format
*dst_efi_fmt
,
34 uint nextents
= ((xfs_efi_log_format_t
*)buf
)->efi_nextents
;
35 uint dst_len
= sizeof(xfs_efi_log_format_t
) + (nextents
- 1) * sizeof(xfs_extent_t
);
36 uint len32
= sizeof(xfs_efi_log_format_32_t
) + (nextents
- 1) * sizeof(xfs_extent_32_t
);
37 uint len64
= sizeof(xfs_efi_log_format_64_t
) + (nextents
- 1) * sizeof(xfs_extent_64_t
);
39 if (len
== dst_len
|| continued
) {
40 memcpy((char *)dst_efi_fmt
, buf
, len
);
42 } else if (len
== len32
) {
43 xfs_efi_log_format_32_t
*src_efi_fmt_32
= (xfs_efi_log_format_32_t
*)buf
;
45 dst_efi_fmt
->efi_type
= src_efi_fmt_32
->efi_type
;
46 dst_efi_fmt
->efi_size
= src_efi_fmt_32
->efi_size
;
47 dst_efi_fmt
->efi_nextents
= src_efi_fmt_32
->efi_nextents
;
48 dst_efi_fmt
->efi_id
= src_efi_fmt_32
->efi_id
;
49 for (i
= 0; i
< dst_efi_fmt
->efi_nextents
; i
++) {
50 dst_efi_fmt
->efi_extents
[i
].ext_start
=
51 src_efi_fmt_32
->efi_extents
[i
].ext_start
;
52 dst_efi_fmt
->efi_extents
[i
].ext_len
=
53 src_efi_fmt_32
->efi_extents
[i
].ext_len
;
56 } else if (len
== len64
) {
57 xfs_efi_log_format_64_t
*src_efi_fmt_64
= (xfs_efi_log_format_64_t
*)buf
;
59 dst_efi_fmt
->efi_type
= src_efi_fmt_64
->efi_type
;
60 dst_efi_fmt
->efi_size
= src_efi_fmt_64
->efi_size
;
61 dst_efi_fmt
->efi_nextents
= src_efi_fmt_64
->efi_nextents
;
62 dst_efi_fmt
->efi_id
= src_efi_fmt_64
->efi_id
;
63 for (i
= 0; i
< dst_efi_fmt
->efi_nextents
; i
++) {
64 dst_efi_fmt
->efi_extents
[i
].ext_start
=
65 src_efi_fmt_64
->efi_extents
[i
].ext_start
;
66 dst_efi_fmt
->efi_extents
[i
].ext_len
=
67 src_efi_fmt_64
->efi_extents
[i
].ext_len
;
71 fprintf(stderr
, _("%s: bad size of efi format: %u; expected %u or %u; nextents = %u\n"),
72 progname
, len
, len32
, len64
, nextents
);
82 xfs_efi_log_format_t
*src_f
, *f
= NULL
;
87 int core_size
= offsetof(xfs_efi_log_format_t
, efi_extents
);
90 * memmove to ensure 8-byte alignment for the long longs in
91 * xfs_efi_log_format_t structure
93 if ((src_f
= (xfs_efi_log_format_t
*)malloc(src_len
)) == NULL
) {
94 fprintf(stderr
, _("%s: xlog_print_trans_efi: malloc failed\n"), progname
);
97 memmove((char*)src_f
, *ptr
, src_len
);
100 /* convert to native format */
101 dst_len
= sizeof(xfs_efi_log_format_t
) + (src_f
->efi_nextents
- 1) * sizeof(xfs_extent_t
);
103 if (continued
&& src_len
< core_size
) {
104 printf(_("EFI: Not enough data to decode further\n"));
109 if ((f
= (xfs_efi_log_format_t
*)malloc(dst_len
)) == NULL
) {
110 fprintf(stderr
, _("%s: xlog_print_trans_efi: malloc failed\n"), progname
);
113 if (xfs_efi_copy_format((char*)src_f
, src_len
, f
, continued
)) {
118 printf(_("EFI: #regs: %d num_extents: %d id: 0x%llx\n"),
119 f
->efi_size
, f
->efi_nextents
, (unsigned long long)f
->efi_id
);
122 printf(_("EFI free extent data skipped (CONTINUE set, no space)\n"));
127 for (i
=0; i
< f
->efi_nextents
; i
++) {
128 printf("(s: 0x%llx, l: %d) ",
129 (unsigned long long)ex
->ext_start
, ex
->ext_len
);
130 if (i
% 4 == 3) printf("\n");
139 } /* xlog_print_trans_efi */
142 xlog_recover_print_efi(
143 xlog_recover_item_t
*item
)
145 xfs_efi_log_format_t
*f
, *src_f
;
148 uint src_len
, dst_len
;
150 src_f
= (xfs_efi_log_format_t
*)item
->ri_buf
[0].i_addr
;
151 src_len
= item
->ri_buf
[0].i_len
;
153 * An xfs_efi_log_format structure contains a variable length array
155 * Each element is of size xfs_extent_32_t or xfs_extent_64_t.
156 * Need to convert to native format.
158 dst_len
= sizeof(xfs_efi_log_format_t
) +
159 (src_f
->efi_nextents
- 1) * sizeof(xfs_extent_t
);
160 if ((f
= (xfs_efi_log_format_t
*)malloc(dst_len
)) == NULL
) {
161 fprintf(stderr
, _("%s: xlog_recover_print_efi: malloc failed\n"),
165 if (xfs_efi_copy_format((char*)src_f
, src_len
, f
, 0)) {
170 printf(_(" EFI: #regs:%d num_extents:%d id:0x%llx\n"),
171 f
->efi_size
, f
->efi_nextents
, (unsigned long long)f
->efi_id
);
174 for (i
=0; i
< f
->efi_nextents
; i
++) {
175 printf("(s: 0x%llx, l: %d) ",
176 (unsigned long long)ex
->ext_start
, ex
->ext_len
);
187 xlog_print_trans_efd(char **ptr
, uint len
)
189 xfs_efd_log_format_t
*f
;
190 xfs_efd_log_format_t lbuf
;
191 /* size without extents at end */
192 uint core_size
= sizeof(xfs_efd_log_format_t
) - sizeof(xfs_extent_t
);
195 * memmove to ensure 8-byte alignment for the long longs in
196 * xfs_efd_log_format_t structure
198 memmove(&lbuf
, *ptr
, MIN(core_size
, len
));
201 if (len
>= core_size
) {
202 printf(_("EFD: #regs: %d num_extents: %d id: 0x%llx\n"),
203 f
->efd_size
, f
->efd_nextents
,
204 (unsigned long long)f
->efd_efi_id
);
206 /* don't print extents as they are not used */
210 printf(_("EFD: Not enough data to decode further\n"));
213 } /* xlog_print_trans_efd */
216 xlog_recover_print_efd(
217 xlog_recover_item_t
*item
)
219 xfs_efd_log_format_t
*f
;
221 f
= (xfs_efd_log_format_t
*)item
->ri_buf
[0].i_addr
;
223 * An xfs_efd_log_format structure contains a variable length array
225 * Each element is of size xfs_extent_32_t or xfs_extent_64_t.
226 * However, the extents are never used and won't be printed.
228 printf(_(" EFD: #regs: %d num_extents: %d id: 0x%llx\n"),
229 f
->efd_size
, f
->efd_nextents
,
230 (unsigned long long)f
->efd_efi_id
);
233 /* Reverse Mapping Update Items */
239 struct xfs_rui_log_format
*dst_fmt
,
242 uint nextents
= ((struct xfs_rui_log_format
*)buf
)->rui_nextents
;
243 uint dst_len
= xfs_rui_log_format_sizeof(nextents
);
245 if (len
== dst_len
|| continued
) {
246 memcpy((char *)dst_fmt
, buf
, len
);
249 fprintf(stderr
, _("%s: bad size of RUI format: %u; expected %u; nextents = %u\n"),
250 progname
, len
, dst_len
, nextents
);
255 xlog_print_trans_rui(
260 struct xfs_rui_log_format
*src_f
, *f
= NULL
;
263 struct xfs_map_extent
*ex
;
268 core_size
= offsetof(struct xfs_rui_log_format
, rui_extents
);
271 * memmove to ensure 8-byte alignment for the long longs in
272 * struct xfs_rui_log_format structure
274 src_f
= malloc(src_len
);
276 fprintf(stderr
, _("%s: %s: malloc failed\n"),
280 memmove((char*)src_f
, *ptr
, src_len
);
283 /* convert to native format */
284 nextents
= src_f
->rui_nextents
;
285 dst_len
= xfs_rui_log_format_sizeof(nextents
);
287 if (continued
&& src_len
< core_size
) {
288 printf(_("RUI: Not enough data to decode further\n"));
295 fprintf(stderr
, _("%s: %s: malloc failed\n"),
299 if (xfs_rui_copy_format((char *)src_f
, src_len
, f
, continued
)) {
304 printf(_("RUI: #regs: %d num_extents: %d id: 0x%llx\n"),
305 f
->rui_size
, f
->rui_nextents
, (unsigned long long)f
->rui_id
);
308 printf(_("RUI extent data skipped (CONTINUE set, no space)\n"));
313 for (i
=0; i
< f
->rui_nextents
; i
++) {
314 printf("(s: 0x%llx, l: %d, own: %lld, off: %llu, f: 0x%x) ",
315 (unsigned long long)ex
->me_startblock
, ex
->me_len
,
316 (long long)ex
->me_owner
,
317 (unsigned long long)ex
->me_startoff
, ex
->me_flags
);
328 xlog_recover_print_rui(
329 struct xlog_recover_item
*item
)
334 src_f
= item
->ri_buf
[0].i_addr
;
335 src_len
= item
->ri_buf
[0].i_len
;
337 xlog_print_trans_rui(&src_f
, src_len
, 0);
341 xlog_print_trans_rud(
345 struct xfs_rud_log_format
*f
;
346 struct xfs_rud_log_format lbuf
;
348 /* size without extents at end */
349 uint core_size
= sizeof(struct xfs_rud_log_format
);
352 * memmove to ensure 8-byte alignment for the long longs in
353 * xfs_efd_log_format_t structure
355 memmove(&lbuf
, *ptr
, MIN(core_size
, len
));
358 if (len
>= core_size
) {
359 printf(_("RUD: #regs: %d id: 0x%llx\n"),
361 (unsigned long long)f
->rud_rui_id
);
363 /* don't print extents as they are not used */
367 printf(_("RUD: Not enough data to decode further\n"));
373 xlog_recover_print_rud(
374 struct xlog_recover_item
*item
)
378 f
= item
->ri_buf
[0].i_addr
;
379 xlog_print_trans_rud(&f
, sizeof(struct xfs_rud_log_format
));
382 /* Reference Count Update Items */
386 struct xfs_cui_log_format
*cui
,
388 struct xfs_cui_log_format
*dst_fmt
,
394 nextents
= cui
->cui_nextents
;
395 dst_len
= xfs_cui_log_format_sizeof(nextents
);
397 if (len
== dst_len
|| continued
) {
398 memcpy(dst_fmt
, cui
, len
);
401 fprintf(stderr
, _("%s: bad size of CUI format: %u; expected %u; nextents = %u\n"),
402 progname
, len
, dst_len
, nextents
);
407 xlog_print_trans_cui(
412 struct xfs_cui_log_format
*src_f
, *f
= NULL
;
415 struct xfs_phys_extent
*ex
;
420 core_size
= offsetof(struct xfs_cui_log_format
, cui_extents
);
422 src_f
= malloc(src_len
);
424 fprintf(stderr
, _("%s: %s: malloc failed\n"),
428 memcpy(src_f
, *ptr
, src_len
);
431 /* convert to native format */
432 nextents
= src_f
->cui_nextents
;
433 dst_len
= xfs_cui_log_format_sizeof(nextents
);
435 if (continued
&& src_len
< core_size
) {
436 printf(_("CUI: Not enough data to decode further\n"));
443 fprintf(stderr
, _("%s: %s: malloc failed\n"),
447 if (xfs_cui_copy_format(src_f
, src_len
, f
, continued
)) {
452 printf(_("CUI: #regs: %d num_extents: %d id: 0x%llx\n"),
453 f
->cui_size
, f
->cui_nextents
, (unsigned long long)f
->cui_id
);
456 printf(_("CUI extent data skipped (CONTINUE set, no space)\n"));
461 for (i
=0; i
< f
->cui_nextents
; i
++) {
462 printf("(s: 0x%llx, l: %d, f: 0x%x) ",
463 (unsigned long long)ex
->pe_startblock
, ex
->pe_len
,
475 xlog_recover_print_cui(
476 struct xlog_recover_item
*item
)
481 src_f
= item
->ri_buf
[0].i_addr
;
482 src_len
= item
->ri_buf
[0].i_len
;
484 xlog_print_trans_cui(&src_f
, src_len
, 0);
488 xlog_print_trans_cud(
492 struct xfs_cud_log_format
*f
;
493 struct xfs_cud_log_format lbuf
;
495 /* size without extents at end */
496 uint core_size
= sizeof(struct xfs_cud_log_format
);
498 memcpy(&lbuf
, *ptr
, MIN(core_size
, len
));
501 if (len
>= core_size
) {
502 printf(_("CUD: #regs: %d id: 0x%llx\n"),
504 (unsigned long long)f
->cud_cui_id
);
506 /* don't print extents as they are not used */
510 printf(_("CUD: Not enough data to decode further\n"));
516 xlog_recover_print_cud(
517 struct xlog_recover_item
*item
)
521 f
= item
->ri_buf
[0].i_addr
;
522 xlog_print_trans_cud(&f
, sizeof(struct xfs_cud_log_format
));
525 /* Block Mapping Update Items */
529 struct xfs_bui_log_format
*bui
,
531 struct xfs_bui_log_format
*dst_fmt
,
537 nextents
= bui
->bui_nextents
;
538 dst_len
= xfs_bui_log_format_sizeof(nextents
);
540 if (len
== dst_len
|| continued
) {
541 memcpy(dst_fmt
, bui
, len
);
544 fprintf(stderr
, _("%s: bad size of BUI format: %u; expected %u; nextents = %u\n"),
545 progname
, len
, dst_len
, nextents
);
550 xlog_print_trans_bui(
555 struct xfs_bui_log_format
*src_f
, *f
= NULL
;
558 struct xfs_map_extent
*ex
;
563 core_size
= offsetof(struct xfs_bui_log_format
, bui_extents
);
565 src_f
= malloc(src_len
);
567 fprintf(stderr
, _("%s: %s: malloc failed\n"),
571 memcpy(src_f
, *ptr
, src_len
);
574 /* convert to native format */
575 nextents
= src_f
->bui_nextents
;
576 dst_len
= xfs_bui_log_format_sizeof(nextents
);
578 if (continued
&& src_len
< core_size
) {
579 printf(_("BUI: Not enough data to decode further\n"));
586 fprintf(stderr
, _("%s: %s: malloc failed\n"),
590 if (xfs_bui_copy_format(src_f
, src_len
, f
, continued
)) {
595 printf(_("BUI: #regs: %d num_extents: %d id: 0x%llx\n"),
596 f
->bui_size
, f
->bui_nextents
, (unsigned long long)f
->bui_id
);
599 printf(_("BUI extent data skipped (CONTINUE set, no space)\n"));
604 for (i
=0; i
< f
->bui_nextents
; i
++) {
605 printf("(s: 0x%llx, l: %d, own: %lld, off: %llu, f: 0x%x) ",
606 (unsigned long long)ex
->me_startblock
, ex
->me_len
,
607 (long long)ex
->me_owner
,
608 (unsigned long long)ex
->me_startoff
, ex
->me_flags
);
619 xlog_recover_print_bui(
620 struct xlog_recover_item
*item
)
625 src_f
= item
->ri_buf
[0].i_addr
;
626 src_len
= item
->ri_buf
[0].i_len
;
628 xlog_print_trans_bui(&src_f
, src_len
, 0);
632 xlog_print_trans_bud(
636 struct xfs_bud_log_format
*f
;
637 struct xfs_bud_log_format lbuf
;
639 /* size without extents at end */
640 uint core_size
= sizeof(struct xfs_bud_log_format
);
642 memcpy(&lbuf
, *ptr
, MIN(core_size
, len
));
645 if (len
>= core_size
) {
646 printf(_("BUD: #regs: %d id: 0x%llx\n"),
648 (unsigned long long)f
->bud_bui_id
);
650 /* don't print extents as they are not used */
654 printf(_("BUD: Not enough data to decode further\n"));
660 xlog_recover_print_bud(
661 struct xlog_recover_item
*item
)
665 f
= item
->ri_buf
[0].i_addr
;
666 xlog_print_trans_bud(&f
, sizeof(struct xfs_bud_log_format
));