ocfs2: Use cpu_to_le16 for e_leaf_clusters in ocfs2_bg_discontig_add_extent.
PATCH 1/1 ocfs2: Use cpu_to_le16 for e_leaf_clusters in ocfs2_bg_discontig_add_extent.
e_leaf_clusters is a le16, so use cpu_to_le16 instead of cpu_to_le32.
--- fs/ocfs2/suballoc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
fs/ocfs2/suballoc.c +1 -1
@@ -348,7 +348,7 @@ static void ocfs2_bg_discontig_add_extent(struct ocfs2_super *osb, rec->e_blkno =cpu_to_le64 (p_blkno); rec->e_cpos =cpu_to_le32 (le16_to_cpu (bg->bg_bits) /le16_to_cpu (cl->cl_bpc)); - rec->e_leaf_clusters =cpu_to_le32 (clusters); + rec->e_leaf_clusters =cpu_to_le16 (clusters);le16_add_cpu (&bg->bg_bits, clusters *le16_to_cpu (cl->cl_bpc));le16_add_cpu (&bg->bg_free_bits_count, clusters *le16_to_cpu (cl->cl_bpc));
Signature · 1 line
1.7.1.GIT
PATCH 1/1 ocfs2: Use cpu_to_le16 for e_leaf_clusters in ocfs2_bg_discontig_add_extent.
Quoted 4 lines · Tao Ma
e_leaf_clustersis a le16, so usecpu_to_le16instead ofcpu_to_le32.Signed-off-by Tao Ma <[email protected]>
You're right that we need to swap as an le16.
fs/ocfs2/suballoc.c static void ocfs2_bg_discontig_add_extent(struct ocfs2_super *osb, · line 351
Quoted 6 lines
fs/ocfs2/suballoc.c +1
-1@@ -348,7 +348,7 @@ static void ocfs2_bg_discontig_add_extent(struct ocfs2_super *osb, rec->e_blkno =cpu_to_le64 (p_blkno); rec->e_cpos =cpu_to_le32 (le16_to_cpu (bg->bg_bits) /le16_to_cpu (cl->cl_bpc)); - rec->e_leaf_clusters =cpu_to_le32 (clusters); + rec->e_leaf_clusters =cpu_to_le16 (clusters);
For a second I was worried, "what about overflow if clusters >
16bits?" Of course, this is coming from discontig stuff which starts at cpg, so it can't overflow. Maybe discontig_add_extent should take "unsigned int clusters" instead of "u32 clusters" to signify that the size of 'clusters isn't important here?
Joel
Signature · 8 lines
"Friends may come and go, but enemies accumulate."
- Thomas Jones
Joel Becker
Consulting Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127PATCH v2 1/1 ocfs2: Use cpu_to_le16 for e_leaf_clusters in ocfs2_bg_discontig_add_extent.
e_leaf_clusters is a le16, so use cpu_to_le16 instead of cpu_to_le32.
What's more, we change 'clusters' to unsigned int to signify that the size of 'clusters' isn't important here.
--- fs/ocfs2/suballoc.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
fs/ocfs2/suballoc.c +2 -2
@@ -336,7 +336,7 @@ out:static void ocfs2_bg_discontig_add_extent (struct ocfs2_super *osb,struct ocfs2_group_desc *bg,struct ocfs2_chain_list *cl, -u64 p_blkno,u32 clusters) +u64 p_blkno,unsigned int clusters) {struct ocfs2_extent_list *el = &bg->bg_list;struct ocfs2_extent_rec *rec;
@@ -348,7 +348,7 @@ static void ocfs2_bg_discontig_add_extent(struct ocfs2_super *osb, rec->e_blkno =cpu_to_le64 (p_blkno); rec->e_cpos =cpu_to_le32 (le16_to_cpu (bg->bg_bits) /le16_to_cpu (cl->cl_bpc)); - rec->e_leaf_clusters =cpu_to_le32 (clusters); + rec->e_leaf_clusters =cpu_to_le16 (clusters);le16_add_cpu (&bg->bg_bits, clusters *le16_to_cpu (cl->cl_bpc));le16_add_cpu (&bg->bg_free_bits_count, clusters *le16_to_cpu (cl->cl_bpc));
Signature · 1 line
1.7.1.GIT
PATCH v2 1/1 ocfs2: Use cpu_to_le16 for e_leaf_clusters in ocfs2_bg_discontig_add_extent.
Quoted 7 lines · Tao Ma
e_leaf_clustersis a le16, so usecpu_to_le16instead ofcpu_to_le32.What's more, we change 'clusters' to unsigned int to signify that the size of 'clusters' isn't important here.
Signed-off-by Tao Ma <[email protected]>
This patch is now in the 'fixes' branch of ocfs2.git.
Joel
Signature · 9 lines
"The question of whether computers can think is just like the question of whether submarines can swim." - Edsger W. Dijkstra Joel Becker Consulting Software Developer Oracle E-mail: joel.becker at oracle.com Phone: (650) 506-8127