From: John L. Hammond Date: Thu, 27 Mar 2014 19:15:26 +0000 (-0500) Subject: LU-4817 osd: fix some leXX_to_cpu() usage issues X-Git-Tag: 2.5.59~54 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=6a9e714c03ab4d328f7ee24e2d01bd0146ef52c7 LU-4817 osd: fix some leXX_to_cpu() usage issues In osd fix some endianness conversion issues, like applying le16_to_cpu() to an integer literal and calling le64_to_cpu() with a 32-bit value. Signed-off-by: John L. Hammond Change-Id: I5c4b9b0c6f5695e1c34f8deac25f8a0c5d547e23 Reviewed-on: http://review.whamcloud.com/9825 Tested-by: Jenkins Reviewed-by: Alex Zhuravlev Tested-by: Maloo Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin --- diff --git a/lustre/osd-ldiskfs/osd_iam_lfix.c b/lustre/osd-ldiskfs/osd_iam_lfix.c index e36c5c8..85a84ad 100644 --- a/lustre/osd-ldiskfs/osd_iam_lfix.c +++ b/lustre/osd-ldiskfs/osd_iam_lfix.c @@ -175,7 +175,7 @@ static int iam_lfix_init(struct iam_leaf *l) ill = iam_get_head(l); count = le16_to_cpu(ill->ill_count); - if (ill->ill_magic == le16_to_cpu(IAM_LEAF_HEADER_MAGIC) && + if (le16_to_cpu(ill->ill_magic) == IAM_LEAF_HEADER_MAGIC && 0 <= count && count <= leaf_count_limit(l)) { l->il_at = l->il_entries = iam_get_lentries(l); result = 0; @@ -186,7 +186,7 @@ static int iam_lfix_init(struct iam_leaf *l) CERROR("Wrong magic in node %llu (#%lu): %#x != %#x or " "wrong count: %d (%d)\n", (unsigned long long)l->il_bh->b_blocknr, obj->i_ino, - ill->ill_magic, le16_to_cpu(IAM_LEAF_HEADER_MAGIC), + le16_to_cpu(ill->ill_magic), IAM_LEAF_HEADER_MAGIC, count, leaf_count_limit(l)); result = -EIO; } diff --git a/lustre/osd-ldiskfs/osd_iam_lvar.c b/lustre/osd-ldiskfs/osd_iam_lvar.c index 7ad8b10..8223711 100644 --- a/lustre/osd-ldiskfs/osd_iam_lvar.c +++ b/lustre/osd-ldiskfs/osd_iam_lvar.c @@ -399,7 +399,7 @@ static int lvar_init(struct iam_leaf *l) head = n_head(l); used = h_used(head); - if (head->vlh_magic == le16_to_cpu(IAM_LVAR_LEAF_MAGIC) && + if (le16_to_cpu(head->vlh_magic) == IAM_LVAR_LEAF_MAGIC && used <= blocksize(l)) { l->il_at = l->il_entries = lvar_lentry(n_start(l)); result = 0; @@ -410,7 +410,7 @@ static int lvar_init(struct iam_leaf *l) CERROR("Wrong magic in node %llu (#%lu): %#x != %#x or " "wrong used: %d", (unsigned long long)l->il_bh->b_blocknr, obj->i_ino, - head->vlh_magic, le16_to_cpu(IAM_LVAR_LEAF_MAGIC), + le16_to_cpu(head->vlh_magic), IAM_LVAR_LEAF_MAGIC, used); result = -EIO; } @@ -862,7 +862,7 @@ static int lvar_node_check(struct iam_path *path, struct iam_frame *frame) struct lvar_root *root; root = (void *)frame->bh->b_data; - if (le64_to_cpu(root->vr_magic) != IAM_LVAR_ROOT_MAGIC) + if (le32_to_cpu(root->vr_magic) != IAM_LVAR_ROOT_MAGIC) return -EIO; limit_correct = dx_root_limit(path); } else @@ -1059,7 +1059,7 @@ static int lvar_guess(struct iam_container *c) result = iam_node_read(c, lvar_root_ptr(c), NULL, &bh); if (result == 0) { root = (void *)bh->b_data; - if (le64_to_cpu(root->vr_magic) == IAM_LVAR_ROOT_MAGIC) { + if (le32_to_cpu(root->vr_magic) == IAM_LVAR_ROOT_MAGIC) { struct iam_descr *descr; descr = c->ic_descr; diff --git a/lustre/osd-ldiskfs/osd_quota_fmt.c b/lustre/osd-ldiskfs/osd_quota_fmt.c index 0088d00..f9b3e9c 100644 --- a/lustre/osd-ldiskfs/osd_quota_fmt.c +++ b/lustre/osd-ldiskfs/osd_quota_fmt.c @@ -244,7 +244,7 @@ int walk_block_dqentry(const struct lu_env *env, struct osd_object *obj, } ret = 1; - if (!le32_to_cpu(dqhead->dqdh_entries)) + if (!le16_to_cpu(dqhead->dqdh_entries)) GOTO(out_buf, ret); ddquot = (struct lustre_disk_dqblk_v2 *)GETENTRIES(buf);