From: crquan@gmail.com
To: NeilBrown <neilb@suse.de>, linux-raid@vger.kernel.org
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
linux-next@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, wshen_gfkd@163.com
Subject: [PATCH] md_print_devices: use le{32,64}_to_cpu to access data correctly
Date: Thu, 20 Nov 2008 19:19:57 +0800 [thread overview]
Message-ID: <1227179997-6394-1-git-send-email-crquan@gmail.com> (raw)
From: Cheng Renquan <crquan@gmail.com>
The previous direct accessing have endian problems,
Sorry for that lacking of thoughtful consideration.
At the same time define a MASK value to get the seconds
value of time conveniently.
Signed-off-by: Cheng Renquan <crquan@gmail.com>
---
This patch can be applied on git://neil.brown.name/md for-next branch.
drivers/md/md.c | 38 +++++++++++++++++++++++---------------
include/linux/raid/md_p.h | 2 ++
2 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index ffc63be..058cf34 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1664,37 +1664,45 @@ static void print_sb_1(struct mdp_superblock_1 *sb)
__u8 *uuid;
uuid = sb->set_uuid;
- printk(KERN_INFO "md: SB: (V:%d) (F:%x) Array-ID:<%02x%02x%02x%02x"
+ printk(KERN_INFO "md: SB: (V:%u) (F:0x%08x) Array-ID:<%02x%02x%02x%02x"
":%02x%02x:%02x%02x:%02x%02x:%02x%02x%02x%02x%02x%02x>\n"
KERN_INFO "md: Name: \"%s\" CT:%Lu\n",
- sb->major_version, sb->feature_map,
+ le32_to_cpu(sb->major_version),
+ le32_to_cpu(sb->feature_map),
uuid[0], uuid[1], uuid[2], uuid[3],
uuid[4], uuid[5], uuid[6], uuid[7],
uuid[8], uuid[9], uuid[10], uuid[11],
uuid[12], uuid[13], uuid[14], uuid[15],
sb->set_name,
- sb->ctime & 0xffffffffffLL);
+ le64_to_cpu(sb->ctime) & MD_SUPERBLOCK_1_TIME_SEC_MASK);
uuid = sb->device_uuid;
- printk(KERN_INFO "md: L%d SZ%Ld RD:%d LO:%d CS:%d DO:%Ld DS:%Ld SO:%Ld"
- " RO:%Ld\n"
+ printk(KERN_INFO "md: L%u SZ%Lu RD:%u LO:%u CS:%u DO:%Lu DS:%Lu SO:%Lu"
+ " RO:%Lu\n"
KERN_INFO "md: Dev:%08x UUID: %02x%02x%02x%02x:%02x%02x:%02x%02x:%02x%02x"
":%02x%02x%02x%02x%02x%02x\n"
- KERN_INFO "md: (F:%d) UT:%Lu Events:%Ld ResyncOffset:%Ld CSUM:%08x\n"
- KERN_INFO "md: (MaxDev:%d) \n",
- sb->level, sb->size, sb->raid_disks,
- sb->layout, sb->chunksize,
- sb->data_offset, sb->data_size,
- sb->super_offset, sb->recovery_offset,
- sb->dev_number,
+ KERN_INFO "md: (F:0x%08x) UT:%Lu Events:%Lu ResyncOffset:%Lu CSUM:0x%08x\n"
+ KERN_INFO "md: (MaxDev:%u) \n",
+ le32_to_cpu(sb->level),
+ le64_to_cpu(sb->size),
+ le32_to_cpu(sb->raid_disks),
+ le32_to_cpu(sb->layout),
+ le32_to_cpu(sb->chunksize),
+ le64_to_cpu(sb->data_offset),
+ le64_to_cpu(sb->data_size),
+ le64_to_cpu(sb->super_offset),
+ le64_to_cpu(sb->recovery_offset),
+ le32_to_cpu(sb->dev_number),
uuid[0], uuid[1], uuid[2], uuid[3],
uuid[4], uuid[5], uuid[6], uuid[7],
uuid[8], uuid[9], uuid[10], uuid[11],
uuid[12], uuid[13], uuid[14], uuid[15],
sb->devflags,
- sb->utime, sb->events,
- sb->resync_offset,
- sb->sb_csum, sb->max_dev
+ le64_to_cpu(sb->utime) & MD_SUPERBLOCK_1_TIME_SEC_MASK,
+ le64_to_cpu(sb->events),
+ le64_to_cpu(sb->resync_offset),
+ le32_to_cpu(sb->sb_csum),
+ le32_to_cpu(sb->max_dev)
);
}
diff --git a/include/linux/raid/md_p.h b/include/linux/raid/md_p.h
index 8b4de4a..269e147 100644
--- a/include/linux/raid/md_p.h
+++ b/include/linux/raid/md_p.h
@@ -194,6 +194,8 @@ static inline __u64 md_event(mdp_super_t *sb) {
return (ev<<32)| sb->events_lo;
}
+#define MD_SUPERBLOCK_1_TIME_SEC_MASK ((1UL<<40) - 1)
+
/*
* The version-1 superblock :
* All numeric fields are little-endian.
--
1.6.0.4.757.g6d002.dirty
Cheng Renquan, Shenzhen, China
next reply other threads:[~2008-11-20 11:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-20 11:19 crquan [this message]
2008-11-20 11:50 ` [PATCH] md_print_devices: use le{32,64}_to_cpu to access data correctly Neil Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1227179997-6394-1-git-send-email-crquan@gmail.com \
--to=crquan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.de \
--cc=sfr@canb.auug.org.au \
--cc=wshen_gfkd@163.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox