[Ocfs2-tools-devel] [PATCH 3/3] debugfs.ocfs2: Add the -t and -T options to the "stat" command.
Sunil Mushran
sunil.mushran at oracle.com
Mon Jun 7 14:58:34 PDT 2010
Why not just -T. Any advantage of having a specific option for
the default.
On 06/07/2010 02:48 PM, Joel Becker wrote:
> The "stat" command walks the extents or chains of an inode to print
> details about its metadata. This can be expensive when there are a lot
> of extents or chains and the user merely wants information from the
> inode itself. The -t and -T options select and deselect traversal of
> the this metadata respectively. The -t option remains the default.
>
> Signed-off-by: Joel Becker<joel.becker at oracle.com>
> ---
> debugfs.ocfs2/commands.c | 55 +++++++++++++++++++++++++++----------
> debugfs.ocfs2/debugfs.ocfs2.8.in | 8 ++++-
> 2 files changed, 46 insertions(+), 17 deletions(-)
>
> diff --git a/debugfs.ocfs2/commands.c b/debugfs.ocfs2/commands.c
> index e546dc2..1f60049 100644
> --- a/debugfs.ocfs2/commands.c
> +++ b/debugfs.ocfs2/commands.c
> @@ -874,7 +874,7 @@ static void do_help (char **args)
> printf ("refcount [-e]<filespec>\t\t\tDump the refcount tree "
> "for the specified inode or refcount block\n");
> printf ("slotmap\t\t\t\t\tShow slot map\n");
> - printf ("stat<filespec>\t\t\t\tShow inode\n");
> + printf ("stat [-t|-T]<filespec>\t\t\t\tShow inode\n");
> printf ("stats [-h]\t\t\t\tShow superblock\n");
> printf ("xattr [-v]<filespec>\t\t\tShow Extended Attributes\n");
> }
> @@ -1041,9 +1041,28 @@ static void do_stat (char **args)
> char *buf = NULL;
> FILE *out;
> errcode_t ret = 0;
> + const char *stat_usage = "usage: stat [-t|-T]<filespec>";
> + int index = 1, traverse = 1;
>
> - if (process_inode_args(args,&blkno))
> + if (!args[index]) {
> + fprintf(stderr, "%s\n", stat_usage);
> + return ;
> + }
> +
> + if (!strncmp(args[index], "-t", 2)) {
> + traverse = 1;
> + index++;
> + } else if (!strncmp(args[index], "-T", 2)) {
> + traverse = 0;
> + index++;
> + }
> +
> + ret = string_to_inode(gbls.fs, gbls.root_blkno, gbls.cwd_blkno,
> + args[index],&blkno);
> + if (ret) {
> + com_err(args[0], ret, "'%s'", args[index]);
> return ;
> + }
>
> buf = gbls.blockbuf;
> ret = ocfs2_read_inode(gbls.fs, blkno, buf);
> @@ -1057,20 +1076,26 @@ static void do_stat (char **args)
> out = open_pager(gbls.interactive);
> dump_inode(out, inode);
>
> - if ((inode->i_flags& OCFS2_LOCAL_ALLOC_FL))
> - dump_local_alloc(out,&(inode->id2.i_lab));
> - else if ((inode->i_flags& OCFS2_CHAIN_FL))
> - ret = traverse_chains(gbls.fs,&(inode->id2.i_chain), out);
> - else if (S_ISLNK(inode->i_mode)&& !inode->i_clusters)
> - dump_fast_symlink(out, (char *)inode->id2.i_symlink);
> - else if (inode->i_flags& OCFS2_DEALLOC_FL)
> - dump_truncate_log(out,&(inode->id2.i_dealloc));
> - else if (!(inode->i_dyn_features& OCFS2_INLINE_DATA_FL))
> - ret = traverse_extents(gbls.fs,&(inode->id2.i_list), out);
> + if (traverse) {
> + if ((inode->i_flags& OCFS2_LOCAL_ALLOC_FL))
> + dump_local_alloc(out,&(inode->id2.i_lab));
> + else if ((inode->i_flags& OCFS2_CHAIN_FL))
> + ret = traverse_chains(gbls.fs,
> + &(inode->id2.i_chain), out);
> + else if (S_ISLNK(inode->i_mode)&& !inode->i_clusters)
> + dump_fast_symlink(out,
> + (char *)inode->id2.i_symlink);
> + else if (inode->i_flags& OCFS2_DEALLOC_FL)
> + dump_truncate_log(out,&(inode->id2.i_dealloc));
> + else if (!(inode->i_dyn_features& OCFS2_INLINE_DATA_FL))
> + ret = traverse_extents(gbls.fs,
> + &(inode->id2.i_list), out);
>
> - if (ret)
> - com_err(args[0], ret, "while traversing inode at block "
> - "%"PRIu64, blkno);
> + if (ret)
> + com_err(args[0], ret,
> + "while traversing inode at block "
> + "%"PRIu64, blkno);
> + }
>
> close_pager(out);
>
> diff --git a/debugfs.ocfs2/debugfs.ocfs2.8.in b/debugfs.ocfs2/debugfs.ocfs2.8.in
> index c4b9cdd..978741c 100644
> --- a/debugfs.ocfs2/debugfs.ocfs2.8.in
> +++ b/debugfs.ocfs2/debugfs.ocfs2.8.in
> @@ -235,8 +235,12 @@ Display the refcount block, and optionally its tree, of the specified inode.
> Display the contents of the \fIslotmap\fR system file.
>
> .TP
> -\fIstat filespec\fR
> -Display the contents of the inode structure for the \fIfilespec\fR.
> +\fIstat [\-t|\-T] filespec\fR
> +Display the contents of the inode structure for the \fIfilespec\fR. The
> +\fI-t\fR ("traverse") option selects traversal of the inode's metadata.
> +The extent tree, chain list, or other extra metadata will be dumped. This
> +is the default. The \fI-T\fR option turns off traversal to reduce the I/O
> +required when basic inode information is needed.
>
> .TP
> \fIstats [\-h] [\-s backup\-number]\fR
>
More information about the Ocfs2-tools-devel
mailing list