Skip to content

Commit ac9affd

Browse files
fdmananakdave
authored andcommitted
btrfs: print-tree: print missing fields for inode items
We are not dumping a lot of fields for an inode item which are useful for debugging whenever we dump a leaf (log replay failure for example), so add them and make it as close as possible to the print tree implementation in btrfs-progs (things like converting timespecs to human readable dates and converting flags to strings are missing since they are not so practical to do in the kernel). Reviewed-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent aab9458 commit ac9affd

1 file changed

Lines changed: 31 additions & 6 deletions

File tree

fs/btrfs/print-tree.c

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,43 @@ static void print_eb_refs_lock(const struct extent_buffer *eb)
227227
#endif
228228
}
229229

230+
static void print_timespec(const struct extent_buffer *eb,
231+
struct btrfs_timespec *timespec,
232+
const char *prefix, const char *suffix)
233+
{
234+
const u64 secs = btrfs_timespec_sec(eb, timespec);
235+
const u32 nsecs = btrfs_timespec_nsec(eb, timespec);
236+
237+
pr_info("%s%llu.%u%s", prefix, secs, nsecs, suffix);
238+
}
239+
240+
static void print_inode_item(const struct extent_buffer *eb, int i)
241+
{
242+
struct btrfs_inode_item *ii = btrfs_item_ptr(eb, i, struct btrfs_inode_item);
243+
244+
pr_info("\t\tinode generation %llu transid %llu size %llu nbytes %llu\n",
245+
btrfs_inode_generation(eb, ii), btrfs_inode_transid(eb, ii),
246+
btrfs_inode_size(eb, ii), btrfs_inode_nbytes(eb, ii));
247+
pr_info("\t\tblock group %llu mode %o links %u uid %u gid %u\n",
248+
btrfs_inode_block_group(eb, ii), btrfs_inode_mode(eb, ii),
249+
btrfs_inode_nlink(eb, ii), btrfs_inode_uid(eb, ii),
250+
btrfs_inode_gid(eb, ii));
251+
pr_info("\t\trdev %llu sequence %llu flags 0x%llx\n",
252+
btrfs_inode_rdev(eb, ii), btrfs_inode_sequence(eb, ii),
253+
btrfs_inode_flags(eb, ii));
254+
print_timespec(eb, &ii->atime, "\t\tatime ", "\n");
255+
print_timespec(eb, &ii->ctime, "\t\tctime ", "\n");
256+
print_timespec(eb, &ii->mtime, "\t\tmtime ", "\n");
257+
print_timespec(eb, &ii->otime, "\t\totime ", "\n");
258+
}
259+
230260
void btrfs_print_leaf(const struct extent_buffer *l)
231261
{
232262
struct btrfs_fs_info *fs_info;
233263
int i;
234264
u32 type, nr;
235265
struct btrfs_root_item *ri;
236266
struct btrfs_dir_item *di;
237-
struct btrfs_inode_item *ii;
238267
struct btrfs_block_group_item *bi;
239268
struct btrfs_file_extent_item *fi;
240269
struct btrfs_extent_data_ref *dref;
@@ -262,11 +291,7 @@ void btrfs_print_leaf(const struct extent_buffer *l)
262291
btrfs_item_offset(l, i), btrfs_item_size(l, i));
263292
switch (type) {
264293
case BTRFS_INODE_ITEM_KEY:
265-
ii = btrfs_item_ptr(l, i, struct btrfs_inode_item);
266-
pr_info("\t\tinode generation %llu size %llu mode %o\n",
267-
btrfs_inode_generation(l, ii),
268-
btrfs_inode_size(l, ii),
269-
btrfs_inode_mode(l, ii));
294+
print_inode_item(l, i);
270295
break;
271296
case BTRFS_DIR_ITEM_KEY:
272297
di = btrfs_item_ptr(l, i, struct btrfs_dir_item);

0 commit comments

Comments
 (0)