[Ocfs2-tools-devel] [PATCH 4/4] libocfs2: add ocfs2_block_to_cluster_start and use it.

Tao Ma tao.ma at oracle.com
Tue Sep 21 01:55:38 PDT 2010


In kernel, we use ocfs2_block_to_cluster_start in
ocfs2_dx_dir_rebalance to rebalance the dx entries.
The libocfs2 uses the wrong ocfs2_blocks_to_clusters
which cause error in the following ocfs2_read_dx_leaves.

So add ocfs2_block_to_cluster_start and use it.

Signed-off-by: Tao Ma <tao.ma at oracle.com>
---
 include/ocfs2/ocfs2.h  |   12 ++++++++++++
 libocfs2/dir_indexed.c |    2 +-
 2 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/include/ocfs2/ocfs2.h b/include/ocfs2/ocfs2.h
index 8fcc9e1..d9fabee 100644
--- a/include/ocfs2/ocfs2.h
+++ b/include/ocfs2/ocfs2.h
@@ -1066,6 +1066,18 @@ static inline uint32_t ocfs2_bytes_to_clusters(ocfs2_filesys *fs,
 	return (uint32_t)ret;
 }
 
+static inline uint64_t ocfs2_block_to_cluster_start(ocfs2_filesys *fs,
+						    uint64_t blocks)
+{
+	int c_to_b_bits =
+		OCFS2_RAW_SB(fs->fs_super)->s_clustersize_bits -
+		OCFS2_RAW_SB(fs->fs_super)->s_blocksize_bits;
+	uint32_t clusters;
+
+	clusters = ocfs2_blocks_to_clusters(fs, blocks);
+	return (uint64_t)clusters << c_to_b_bits;
+}
+
 static inline uint64_t ocfs2_blocks_to_bytes(ocfs2_filesys *fs,
 					     uint64_t blocks)
 {
diff --git a/libocfs2/dir_indexed.c b/libocfs2/dir_indexed.c
index d0d6d17..8213f3d 100644
--- a/libocfs2/dir_indexed.c
+++ b/libocfs2/dir_indexed.c
@@ -903,7 +903,7 @@ static errcode_t ocfs2_dx_dir_rebalance(ocfs2_filesys *fs,
 	ret = ocfs2_malloc_block(fs->fs_io, (char **)(&tmp_dx_leaf));
 	if (ret)
 		goto out;
-	orig_leaves_start = ocfs2_blocks_to_clusters(fs, leaf_blkno);
+	orig_leaves_start = ocfs2_block_to_cluster_start(fs, leaf_blkno);
 	ret = ocfs2_read_dx_leaves(fs, orig_leaves_start, num_dx_leaves,
 					orig_dx_leaves);
 	if (ret)
-- 
1.7.1.GIT




More information about the Ocfs2-tools-devel mailing list