[Ocfs2-tools-devel] [patch 10/11] Modify debugfs.ocfs2 to be show
sparse files.
Mark Fasheh
mark.fasheh at oracle.com
Fri Aug 17 15:17:57 PDT 2007
On Thu, Aug 16, 2007 at 01:56:20AM +0800, tao.ma wrote:
> Mark has modified some, he will check in some patches for it soon.
> ===================================================================
> --- test.ocfs2-tools.orig/debugfs.ocfs2/commands.c 2007-08-16 00:27:43.000000000 -0400
> +++ test.ocfs2-tools/debugfs.ocfs2/commands.c 2007-08-16 00:36:28.000000000 -0400
> @@ -426,21 +426,33 @@ static errcode_t find_block_offset(ocfs2
> errcode_t ret = 0;
> char *buf = NULL;
> int i;
> - uint32_t clstoff;
> + uint32_t clstoff, clusters;
> uint32_t tmp;
>
> clstoff = ocfs2_blocks_to_clusters(fs, blkoff);
>
> for (i = 0; i < el->l_next_free_rec; ++i) {
> rec = &(el->l_recs[i]);
> + clusters = ocfs2_rec_clusters(el->l_tree_depth, rec);
>
> - /* TODO Fix to handle sparse trees */
> - if (clstoff >= (rec->e_cpos + rec->e_clusters))
> + /* For a sparse file, we may find an empty record.
> + * Just skip it.
> + */
> + if (clusters)
> + continue;
Don't you mean "if (!clusters)" here?
> @@ -482,11 +494,22 @@ static errcode_t traverse_extents (ocfs2
> errcode_t ret = 0;
> char *buf = NULL;
> int i;
> + uint32_t clusters;
>
> dump_extent_list (out, el);
>
> for (i = 0; i < el->l_next_free_rec; ++i) {
> rec = &(el->l_recs[i]);
> + clusters = ocfs2_rec_clusters(el->l_tree_depth, rec);
> +
> + /* In a unsuccessful insertion, we may shift a tree
> + * add a new branch for it and do no insertion. So we
> + * may meet a extent block which have
> + * clusters == 0, this should only be happen
> + * in the last extent rec. */
> + if (!clusters && i == el->l_next_free_rec - 1)
> + break;
if (!clusters && i == 0 && i == el->l_next_free_rec - 1)
break;
--
Mark Fasheh
Senior Software Developer, Oracle
mark.fasheh at oracle.com
More information about the Ocfs2-tools-devel
mailing list