Commit 1d46dc08 authored by Mark Fasheh's avatar Mark Fasheh

ocfs2: fix leaf start calculation in ocfs2_dx_dir_rebalance()

ocfs2_dx_dir_rebalance() is passed the block offset of a dx leaf which needs
rebalancing. Since we rebalance an entire cluster at a time however, this
function needs to calculate the beginning of that cluster, in blocks. The
calculation was wrong, which would result in a read of non-leaf blocks. Fix
the calculation by adding ocfs2_block_to_cluster_start() which is a more
straight-forward way of determining this.
Reported-by: default avatarTristan Ye <tristan.ye@oracle.com>
Signed-off-by: default avatarMark Fasheh <mfasheh@suse.com>
parent b80b549c
......@@ -3941,8 +3941,7 @@ static int ocfs2_dx_dir_rebalance(struct ocfs2_super *osb, struct inode *dir,
goto out_commit;
}
orig_leaves_start = leaf_blkno & ~(osb->s_clustersize_bits -
osb->sb->s_blocksize_bits);
orig_leaves_start = ocfs2_block_to_cluster_start(dir->i_sb, leaf_blkno);
ret = ocfs2_read_dx_leaves(dir, orig_leaves_start, num_dx_leaves,
orig_dx_leaves);
if (ret) {
......
......@@ -582,6 +582,16 @@ static inline u64 ocfs2_clusters_to_bytes(struct super_block *sb,
return (u64)clusters << OCFS2_SB(sb)->s_clustersize_bits;
}
static inline u64 ocfs2_block_to_cluster_start(struct super_block *sb,
u64 blocks)
{
int bits = OCFS2_SB(sb)->s_clustersize_bits - sb->s_blocksize_bits;
unsigned int clusters;
clusters = ocfs2_blocks_to_clusters(sb, blocks);
return (u64)clusters << bits;
}
static inline u64 ocfs2_align_bytes_to_clusters(struct super_block *sb,
u64 bytes)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment