~davewalker/ubuntu/natty/ocfs2-tools/bug_363877

« back to all changes in this revision

Viewing changes to debugfs.ocfs2/dump.c

  • Committer: Bazaar Package Importer
  • Author(s): Andres Rodriguez
  • Date: 2011-01-14 12:46:49 UTC
  • mfrom: (1.1.10 upstream) (0.1.10 sid)
  • Revision ID: james.westby@ubuntu.com-20110114124649-vbe5qz211f3zxwuf
Tags: 1.6.3-1ubuntu1
* Merge from debian unstable (LP: #703008).  Remaining changes:
  - Fix configure tests for ld --as-needed.
  - Fix build failure with ld --no-add-needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
99
99
                fprintf(out, "%02X", sb->s_uuid[i]);
100
100
        fprintf(out, "\n");
101
101
        fprintf(out, "\tHash: %u (0x%x)\n", sb->s_uuid_hash, sb->s_uuid_hash);
 
102
        for (i = 0; i < 3; i++)
 
103
                fprintf(out, "\tDX Seed[%d]: 0x%08x\n", i, sb->s_dx_seed[i]);
 
104
 
102
105
        if (ocfs2_userspace_stack(sb))
103
106
                fprintf(out,
104
107
                        "\tCluster stack: %s\n"
164
167
 * dump_block_check
165
168
 *
166
169
 */
167
 
void dump_block_check(FILE *out, struct ocfs2_block_check *bc)
 
170
void dump_block_check(FILE *out, struct ocfs2_block_check *bc, void *block)
168
171
{
 
172
        struct ocfs2_block_check tmp = *bc;
 
173
        int crc_fail;
 
174
 
 
175
        /* Re-compute based on what we got from disk */
 
176
        ocfs2_compute_meta_ecc(gbls.fs, block, bc);
 
177
 
 
178
        crc_fail = memcmp(bc, &tmp, sizeof(*bc));
 
179
 
169
180
        fprintf(out, "\tCRC32: %.8"PRIx32"   ECC: %.4"PRIx16"\n",
170
 
                le32_to_cpu(bc->bc_crc32e), le16_to_cpu(bc->bc_ecc));
 
181
                le32_to_cpu(tmp.bc_crc32e), le16_to_cpu(tmp.bc_ecc));
 
182
        if (crc_fail)
 
183
                fprintf(out, "\t**FAILED CHECKSUM** Computed CRC32: %.8"
 
184
                        PRIx32"   ECC: %.4"PRIx16"\n",
 
185
                        le32_to_cpu(bc->bc_crc32e), le16_to_cpu(bc->bc_ecc));
 
186
 
 
187
        /* Leave the block as we found it. */
 
188
        *bc = tmp;
171
189
}
172
190
 
173
191
/*
239
257
                g_string_append(dyn_features, "InlineXattr ");
240
258
        if (in->i_dyn_features & OCFS2_INDEXED_DIR_FL)
241
259
                g_string_append(dyn_features, "IndexedDir ");
 
260
        if (in->i_dyn_features & OCFS2_HAS_REFCOUNT_FL)
 
261
                g_string_append(dyn_features, "Refcounted ");
242
262
 
243
263
        fprintf(out, "\tInode: %"PRIu64"   Mode: 0%0o   Generation: %u (0x%x)\n",
244
264
                (uint64_t)in->i_blkno, mode, in->i_generation, in->i_generation);
246
266
        fprintf(out, "\tFS Generation: %u (0x%x)\n", in->i_fs_generation,
247
267
                in->i_fs_generation);
248
268
 
249
 
        dump_block_check(out, &in->i_check);
 
269
        dump_block_check(out, &in->i_check, in);
250
270
 
251
271
        fprintf(out, "\tType: %s   Attr: 0x%x   Flags: %s\n", str, in->i_attr,
252
272
                flags->str);
284
304
        fprintf(out, "\tmtime_nsec: 0x%08"PRIx32" -- %u\n",
285
305
                in->i_mtime_nsec, in->i_mtime_nsec);
286
306
 
 
307
        fprintf(out, "\tRefcount Block: %"PRIu64"\n",
 
308
                (uint64_t)in->i_refcount_loc);
 
309
 
287
310
        fprintf(out, "\tLast Extblk: %"PRIu64"   Orphan Slot: %d\n",
288
311
                (uint64_t)in->i_last_eb_blk, in->i_orphaned_slot);
289
312
        if (in->i_suballoc_slot == (uint16_t)OCFS2_INVALID_SLOT)
290
313
                strcpy(tmp_str, "Global");
291
314
        else
292
315
                sprintf(tmp_str, "%d", in->i_suballoc_slot);
293
 
        fprintf(out, "\tSub Alloc Slot: %s   Sub Alloc Bit: %u\n",
 
316
        fprintf(out, "\tSub Alloc Slot: %s   Sub Alloc Bit: %u",
294
317
                tmp_str, in->i_suballoc_bit);
295
318
 
 
319
        if (in->i_suballoc_loc)
 
320
                fprintf(out, "   Sub Alloc Group %"PRIu64"\n",
 
321
                        in->i_suballoc_loc);
 
322
        else
 
323
                fprintf(out, "\n");
 
324
 
296
325
        if (in->i_flags & OCFS2_BITMAP_FL)
297
326
                fprintf(out, "\tBitmap Total: %u   Used: %u   Free: %u\n",
298
327
                       in->id1.bitmap1.i_total, in->id1.bitmap1.i_used,
310
339
        if (in->i_dyn_features & OCFS2_INLINE_DATA_FL) {
311
340
                fprintf(out, "\tInline Data Max: %u\n",
312
341
                        in->id2.i_data.id_count);
 
342
        } else if (in->i_dyn_features & OCFS2_INDEXED_DIR_FL) {
 
343
                fprintf(out, "\tIndexed Tree Root: %"PRIu64"\n",
 
344
                        (uint64_t)in->i_dx_root);
313
345
        }
314
346
 
315
347
        if (flags)
357
389
        struct ocfs2_extent_rec *rec;
358
390
        int i;
359
391
        uint32_t clusters;
 
392
        char flags[PATH_MAX];
360
393
 
361
394
        fprintf(out, "\tTree Depth: %u   Count: %u   Next Free Rec: %u\n",
362
395
                ext->l_tree_depth, ext->l_count, ext->l_next_free_rec);
379
412
                        fprintf(out, "\t%-2d %-11u   %-12u   %"PRIu64"\n",
380
413
                                i, rec->e_cpos, clusters,
381
414
                                (uint64_t)rec->e_blkno);
382
 
                else
 
415
                else {
 
416
                        flags[0] = '\0';
 
417
                        if (ocfs2_snprint_extent_flags(flags, PATH_MAX,
 
418
                                                       rec->e_flags))
 
419
                                flags[0] = '\0';
 
420
 
383
421
                        fprintf(out,
384
 
                                "\t%-2d %-11u   %-12u   %-13"PRIu64"   0x%x\n",
 
422
                                "\t%-2d %-11u   %-12u   "
 
423
                                "%-13"PRIu64"   0x%x %s\n",
385
424
                                i, rec->e_cpos, clusters,
386
 
                                (uint64_t)rec->e_blkno, rec->e_flags);
 
425
                                (uint64_t)rec->e_blkno, rec->e_flags, flags);
 
426
                }
387
427
        }
388
428
 
389
429
bail:
396
436
 */
397
437
void dump_extent_block (FILE *out, struct ocfs2_extent_block *blk)
398
438
{
399
 
        fprintf (out, "\tSubAlloc Bit: %u   SubAlloc Slot: %u\n",
 
439
        fprintf(out, "\tSubAlloc Bit: %u   SubAlloc Slot: %u",
400
440
                 blk->h_suballoc_bit, blk->h_suballoc_slot);
401
441
 
 
442
        if (blk->h_suballoc_loc)
 
443
                fprintf(out, "   SubAlloc Group: %"PRIu64"\n",
 
444
                        blk->h_suballoc_loc);
 
445
        else
 
446
                fprintf(out, "\n");
 
447
 
402
448
        fprintf (out, "\tBlknum: %"PRIu64"   Next Leaf: %"PRIu64"\n",
403
449
                 (uint64_t)blk->h_blkno, (uint64_t)blk->h_next_leaf_blk);
404
450
 
405
 
        dump_block_check(out, &blk->h_check);
 
451
        dump_block_check(out, &blk->h_check, blk);
406
452
 
407
453
        return ;
408
454
}
422
468
                         grp->bg_chain,
423
469
                         (uint64_t)grp->bg_parent_dinode,
424
470
                         grp->bg_generation);
425
 
                dump_block_check(out, &grp->bg_check);
 
471
                dump_block_check(out, &grp->bg_check, grp);
426
472
 
427
473
                fprintf(out, "\t##   %-15s   %-6s   %-6s   %-6s   %-6s   %-6s\n",
428
474
                        "Block#", "Total", "Used", "Free", "Contig", "Size");
435
481
                (grp->bg_bits - grp->bg_free_bits_count),
436
482
                grp->bg_free_bits_count, max_contig_free_bits, grp->bg_size);
437
483
 
 
484
        if (ocfs2_gd_is_discontig(grp))
 
485
                dump_extent_list(out, &grp->bg_list);
 
486
 
438
487
        return ;
439
488
}
440
489
 
442
491
 * dump_dir_entry()
443
492
 *
444
493
 */
445
 
int  dump_dir_entry (struct ocfs2_dir_entry *rec, int offset, int blocksize,
446
 
                     char *buf, void *priv_data)
 
494
int  dump_dir_entry (struct ocfs2_dir_entry *rec, uint64_t blocknr, int offset,
 
495
                     int blocksize, char *buf, void *priv_data)
447
496
{
448
497
        list_dir_opts *ls = (list_dir_opts *)priv_data;
449
498
        char tmp = rec->name[rec->name_len];
477
526
}
478
527
 
479
528
/*
 
529
 * dump_dir_trailer()
 
530
 */
 
531
static void dump_dir_trailer(FILE *out, struct ocfs2_dir_block_trailer *trailer)
 
532
{
 
533
        fprintf(out,
 
534
                "\tTrailer Block: %-15"PRIu64" Inode: %-15"PRIu64" rec_len: %-4u\n",
 
535
                trailer->db_blkno, trailer->db_parent_dinode,
 
536
                trailer->db_compat_rec_len);
 
537
        fprintf(out,
 
538
                "\tLargest hole: %u  Next in list: %-15"PRIu64"\n",
 
539
                trailer->db_free_rec_len, trailer->db_free_next);
 
540
        dump_block_check(out, &trailer->db_check, trailer);
 
541
}
 
542
 
 
543
/*
480
544
 * dump_dir_block()
481
545
 *
482
546
 */
494
558
        };
495
559
 
496
560
        if (!strncmp((char *)trailer->db_signature, OCFS2_DIR_TRAILER_SIGNATURE,
497
 
                     sizeof(trailer->db_signature))) {
498
 
                fprintf(out,
499
 
                        "\tTrailer Block: %-15"PRIu64" Inode: %-15"PRIu64" rec_len: %-4u\n",
500
 
                        trailer->db_blkno, trailer->db_parent_dinode,
501
 
                        trailer->db_compat_rec_len);
502
 
                dump_block_check(out, &trailer->db_check);
503
 
        } else
 
561
                     sizeof(trailer->db_signature)))
 
562
                dump_dir_trailer(out, trailer);
 
563
        else
504
564
                end = gbls.fs->fs_blocksize;
505
565
 
506
566
        fprintf(out, "\tEntries:\n");
514
574
                        return;
515
575
                }
516
576
 
517
 
                dump_dir_entry(dirent, offset, gbls.fs->fs_blocksize, NULL,
 
577
                dump_dir_entry(dirent, 0, offset, gbls.fs->fs_blocksize, NULL,
518
578
                               &ls_opts);
519
579
                offset += dirent->rec_len;
520
580
        }
521
581
}
522
582
 
 
583
static void dump_dx_entry(FILE *out, int i, struct ocfs2_dx_entry *dx_entry)
 
584
{
 
585
        fprintf(out, "\t %-2d (0x%08x 0x%08x)    %-13"PRIu64"\n",
 
586
                i, dx_entry->dx_major_hash, dx_entry->dx_minor_hash,
 
587
                (uint64_t)dx_entry->dx_dirent_blk);
 
588
}
 
589
 
 
590
static void dump_dx_entry_list(FILE *out, struct ocfs2_dx_entry_list *dl_list,
 
591
                               int traverse)
 
592
{
 
593
        int i;
 
594
 
 
595
        fprintf(out, "\tCount: %u  Num Used: %u\n",
 
596
                dl_list->de_count, dl_list->de_num_used);
 
597
 
 
598
        if (traverse) {
 
599
                fprintf(out, "\t## %-11s         %-13s\n", "Hash (Major Minor)",
 
600
                        "Dir Block#");
 
601
 
 
602
                for (i = 0; i < dl_list->de_num_used; i++)
 
603
                        dump_dx_entry(out, i, &dl_list->de_entries[i]);
 
604
        }
 
605
}
 
606
 
 
607
void dump_dx_root(FILE *out, struct ocfs2_dx_root_block *dr)
 
608
{
 
609
        char tmp_str[30];
 
610
        GString *flags = NULL;
 
611
 
 
612
        flags = g_string_new(NULL);
 
613
        if (dr->dr_flags & OCFS2_DX_FLAG_INLINE)
 
614
                g_string_append(flags, "Inline ");
 
615
 
 
616
        fprintf(out, "\tDir Index Root: %"PRIu64"   FS Generation: %u (0x%x)\n",
 
617
                (uint64_t)dr->dr_blkno, dr->dr_fs_generation,
 
618
                dr->dr_fs_generation);
 
619
 
 
620
        fprintf(out, "\tClusters: %u   Last Extblk: %"PRIu64"   "
 
621
                "Dir Inode: %"PRIu64"\n",
 
622
                dr->dr_clusters, (uint64_t)dr->dr_last_eb_blk,
 
623
                (uint64_t)dr->dr_dir_blkno);
 
624
 
 
625
        if (dr->dr_suballoc_slot == (uint16_t)OCFS2_INVALID_SLOT)
 
626
                strcpy(tmp_str, "Invalid Slot");
 
627
        else
 
628
                sprintf(tmp_str, "%d", dr->dr_suballoc_slot);
 
629
        fprintf(out, "\tSub Alloc Slot: %s   Sub Alloc Bit: %u",
 
630
                tmp_str, dr->dr_suballoc_bit);
 
631
 
 
632
        if (dr->dr_suballoc_loc)
 
633
                fprintf(out, "   SubAlloc Group: %"PRIu64"\n",
 
634
                        dr->dr_suballoc_loc);
 
635
        else
 
636
                fprintf(out, "\n");
 
637
 
 
638
        fprintf(out, "Flags: (0x%x) %s\n", dr->dr_flags, flags->str);
 
639
 
 
640
        fprintf(out, "\tTotal Entry Count: %d\n", dr->dr_num_entries);
 
641
 
 
642
        dump_block_check(out, &dr->dr_check, dr);
 
643
 
 
644
        if (dr->dr_flags & OCFS2_DX_FLAG_INLINE)
 
645
                dump_dx_entry_list(out, &dr->dr_entries, 0);
 
646
 
 
647
        if (flags)
 
648
                g_string_free(flags, 1);
 
649
}
 
650
 
 
651
void dump_dx_leaf (FILE *out, struct ocfs2_dx_leaf *dx_leaf)
 
652
{
 
653
        fprintf(out, "\tDir Index Leaf: %"PRIu64"  FS Generation: %u (0x%x)\n",
 
654
                (uint64_t)dx_leaf->dl_blkno, dx_leaf->dl_fs_generation,
 
655
                dx_leaf->dl_fs_generation);
 
656
        dump_block_check(out, &dx_leaf->dl_check, dx_leaf);
 
657
 
 
658
        dump_dx_entry_list(out, &dx_leaf->dl_list, 1);
 
659
}
 
660
 
 
661
static int entries_iter(ocfs2_filesys *fs,
 
662
                        struct ocfs2_dx_entry_list *entry_list,
 
663
                        struct ocfs2_dx_root_block *dx_root,
 
664
                        struct ocfs2_dx_leaf *dx_leaf,
 
665
                        void *priv_data)
 
666
{
 
667
        FILE *out = priv_data;
 
668
 
 
669
        if (dx_leaf) {
 
670
                dump_dx_leaf(out, dx_leaf);
 
671
                return 0;
 
672
        }
 
673
 
 
674
        /* Inline entries. Dump the list directly. */
 
675
        dump_dx_entry_list(out, entry_list, 1);
 
676
 
 
677
        return 0;
 
678
}
 
679
 
 
680
void dump_dx_entries(FILE *out, struct ocfs2_dinode *inode)
 
681
{
 
682
        struct ocfs2_dx_root_block *dx_root;
 
683
        uint64_t dx_blkno;
 
684
        char *buf = NULL;
 
685
        errcode_t ret = 0;
 
686
 
 
687
        if (ocfs2_malloc_block(gbls.fs->fs_io, &buf))
 
688
                return;
 
689
 
 
690
        if (!(ocfs2_dir_indexed(inode)))
 
691
                return;
 
692
 
 
693
        dx_blkno = (uint64_t) inode->i_dx_root;
 
694
 
 
695
        ret = ocfs2_read_dx_root(gbls.fs, dx_blkno, buf);
 
696
        if (ret)
 
697
                return;
 
698
 
 
699
        dx_root = (struct ocfs2_dx_root_block *)buf;
 
700
        dump_dx_root(out, dx_root);
 
701
 
 
702
        ocfs2_dx_entries_iterate(gbls.fs, inode, 0, entries_iter, out);
 
703
        return;
 
704
}
 
705
 
 
706
static int dx_space_iter(ocfs2_filesys *fs,
 
707
                         uint64_t blkno,
 
708
                         struct ocfs2_dir_block_trailer *trailer,
 
709
                         char *dirblock,
 
710
                         void *priv_data)
 
711
{
 
712
        FILE *out = priv_data;
 
713
 
 
714
        dump_dir_trailer(out, trailer);
 
715
 
 
716
        return 0;
 
717
}
 
718
 
 
719
void dump_dx_space(FILE *out, struct ocfs2_dinode *inode,
 
720
                   struct ocfs2_dx_root_block *dx_root)
 
721
{
 
722
        ocfs2_dx_frees_iterate(gbls.fs, inode, dx_root, 0, dx_space_iter, out);
 
723
}
 
724
 
523
725
/*
524
726
 * dump_jbd_header()
525
727
 *
695
897
                break;
696
898
        case DUMP_BLOCK_GROUP_DESCRIPTOR:
697
899
                fprintf(out, "Group\n");
698
 
                ocfs2_swap_group_desc((struct ocfs2_group_desc *)buf);
 
900
                ocfs2_swap_group_desc_to_cpu(gbls.fs,
 
901
                                      (struct ocfs2_group_desc *)buf);
699
902
                dump_group_descriptor (out, (struct ocfs2_group_desc *)buf, 0);
700
903
                fprintf (out, "\n");
701
904
                break;
1028
1231
                " %u\textents: %u\tscore: %.0f\n", ino,
1029
1232
                frag_level, clusters, extents, frag_level * clusters_per_mb);
1030
1233
}
 
1234
 
 
1235
void dump_refcount_block(FILE *out, struct ocfs2_refcount_block *rb)
 
1236
{
 
1237
        char flags[PATH_MAX];
 
1238
 
 
1239
        fprintf(out, "\tSubAlloc Bit: %u   SubAlloc Slot: %u",
 
1240
                rb->rf_suballoc_bit, rb->rf_suballoc_slot);
 
1241
 
 
1242
        if (rb->rf_suballoc_loc)
 
1243
                fprintf(out, "   SubAlloc Group: %"PRIu64"\n",
 
1244
                        rb->rf_suballoc_loc);
 
1245
        else
 
1246
                fprintf(out, "\n");
 
1247
 
 
1248
        fprintf(out, "\tFS Generation: %u (0x%x)\n", rb->rf_fs_generation,
 
1249
                rb->rf_fs_generation);
 
1250
        fprintf(out, "\tBlknum: %"PRIu64"   Parent: %"PRIu64"\n",
 
1251
                (uint64_t)rb->rf_blkno, (uint64_t)rb->rf_parent);
 
1252
        fprintf(out, "\tCpos: %"PRIu64"   Last Leaf block: %"PRIu64"\n",
 
1253
                (uint64_t)rb->rf_cpos, (uint64_t)rb->rf_last_eb_blk);
 
1254
        fprintf(out, "\tReftree Count: %u   Ref clusters: %u\n",
 
1255
                rb->rf_count, rb->rf_clusters);
 
1256
 
 
1257
        flags[0] = '\0';
 
1258
        if (ocfs2_snprint_refcount_flags(flags, PATH_MAX, rb->rf_flags))
 
1259
                flags[0] = '\0';
 
1260
        fprintf(out, "\tFlags: 0x%x %s\n", rb->rf_flags, flags);
 
1261
        dump_block_check(out, &rb->rf_check, rb);
 
1262
 
 
1263
        return;
 
1264
 
 
1265
}
 
1266
 
 
1267
void dump_refcount_records(FILE *out, struct ocfs2_refcount_block *rb)
 
1268
{
 
1269
        int i;
 
1270
        struct ocfs2_refcount_list *rl = &rb->rf_records;
 
1271
 
 
1272
        fprintf(out, "\tRefcount records: %u   Used: %u\n",
 
1273
                rl->rl_count, rl->rl_used);
 
1274
        fprintf(out, "\t### %-20s   %-12s   %-12s\n", "Physical cpos",
 
1275
                        "Clusters", "Reference count");
 
1276
 
 
1277
        for (i = 0; i < rl->rl_used; i++) {
 
1278
                fprintf(out,
 
1279
                        "\t%-3d %-20"PRIu64"   %-12"PRIu32"   %"PRIu32"\n",
 
1280
                        i, rl->rl_recs[i].r_cpos, rl->rl_recs[i].r_clusters,
 
1281
                        rl->rl_recs[i].r_refcount);
 
1282
        }
 
1283
}
 
1284
 
 
1285