Whamcloud - gitweb
LU-4817 osd: fix some leXX_to_cpu() usage issues 25/9825/4
authorJohn L. Hammond <john.hammond@intel.com>
Thu, 27 Mar 2014 19:15:26 +0000 (14:15 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 6 May 2014 02:31:04 +0000 (02:31 +0000)
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 <john.hammond@intel.com>
Change-Id: I5c4b9b0c6f5695e1c34f8deac25f8a0c5d547e23
Reviewed-on: http://review.whamcloud.com/9825
Tested-by: Jenkins
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/osd-ldiskfs/osd_iam_lfix.c
lustre/osd-ldiskfs/osd_iam_lvar.c
lustre/osd-ldiskfs/osd_quota_fmt.c

index e36c5c8..85a84ad 100644 (file)
@@ -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;
         }
index 7ad8b10..8223711 100644 (file)
@@ -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;
index 0088d00..f9b3e9c 100644 (file)
@@ -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);