From: Benny Halevy <bhalevy@panasas.com>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>, linux-nfs@vger.kernel.org
Subject: Re: [PATCH RFC 02/13] sunrpc: ntoh -> be*_to_cpu
Date: Sun, 13 Sep 2009 19:14:00 +0300 [thread overview]
Message-ID: <4AAD1A48.1040801@panasas.com> (raw)
In-Reply-To: <20090912140001.GD5858@ZenIV.linux.org.uk>
On Sep. 12, 2009, 17:00 +0300, Al Viro <viro@ZenIV.linux.org.uk> wrote:
> On Wed, Aug 12, 2009 at 06:21:48PM +0300, Benny Halevy wrote:
>> ntohl is already defined as be32_to_cpu.
>> be64_to_cpu has architecture specific optimized implementations.
>
>> static inline __be32 *
>> xdr_decode_hyper(__be32 *p, __u64 *valp)
>> {
>> - *valp = ((__u64) ntohl(*p++)) << 32;
>> - *valp |= ntohl(*p++);
>> - return p;
>> + *valp = be64_to_cpup((__be64 *)p);
>> + return p + 2;
>> }
>
> Erm... Who has promised you that p will be 64bit-aligned?
Good point.
The following should do then, right?
Benny
git diff --stat -p
include/linux/sunrpc/xdr.h | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h
index 7da466b..f5cc089 100644
--- a/include/linux/sunrpc/xdr.h
+++ b/include/linux/sunrpc/xdr.h
@@ -11,6 +11,7 @@
#include <linux/uio.h>
#include <asm/byteorder.h>
+#include <asm/unaligned.h>
#include <linux/scatterlist.h>
/*
@@ -117,14 +118,14 @@ static inline __be32 *xdr_encode_array(__be32 *p, const void *s, unsigned int le
static inline __be32 *
xdr_encode_hyper(__be32 *p, __u64 val)
{
- *(__be64 *)p = cpu_to_be64(val);
+ put_unaligned_be64(val, p);
return p + 2;
}
static inline __be32 *
xdr_decode_hyper(__be32 *p, __u64 *valp)
{
- *valp = be64_to_cpup((__be64 *)p);
+ *valp = get_unaligned_be64(p);
return p + 2;
}
next prev parent reply other threads:[~2009-09-13 16:13 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-12 15:15 [PATCH RFC 0/13] xdr macros cleanup Benny Halevy
2009-08-12 15:21 ` [PATCH RFC 01/13] sunrpc: hton -> cpu_to_be* Benny Halevy
2009-08-12 15:21 ` [PATCH RFC 02/13] sunrpc: ntoh -> be*_to_cpu Benny Halevy
2009-09-12 14:00 ` Al Viro
2009-09-13 16:14 ` Benny Halevy [this message]
2009-09-15 16:05 ` [PATCH] sunrpc: xdr_xcode_hyper helpers cannot presume 64-bit alignment Benny Halevy
2009-08-12 15:21 ` [PATCH RFC 03/13] sunrpc: introduce 32-bit Xcoding helpers Benny Halevy
2009-08-12 20:12 ` Trond Myklebust
2009-08-12 15:21 ` [PATCH RFC 04/13] nfs: nfs4xdr: get rid of WRITE32 Benny Halevy
2009-08-12 15:22 ` [PATCH RFC 05/13] nfs: nfs4xdr: get rid of WRITE64 Benny Halevy
2009-08-12 15:22 ` [PATCH RFC 06/13] nfs: nfs4xdr: get rid of WRITEMEM Benny Halevy
2009-08-12 15:22 ` [PATCH RFC 07/13] nfs: nfs4xdr: merge xdr_encode_int+xdr_encode_opaque_fixed into xdr_encode_opaque Benny Halevy
2009-08-12 15:22 ` [PATCH RFC 08/13] nfs: nfs4xdr: change RESERVE_SPACE macro into a static helper Benny Halevy
2009-08-12 15:22 ` [PATCH RFC 09/13] nfs: nfs4xdr: get rid of READ32 Benny Halevy
2009-08-12 15:22 ` [PATCH RFC 10/13] nfs: nfs4xdr: get rid of READ64 Benny Halevy
2009-08-12 15:22 ` [PATCH RFC 11/13] nfs: nfs4xdr: get rid of READTIME macro Benny Halevy
2009-08-12 15:22 ` [PATCH RFC 12/13] nfs: nfs4xdr: change COPYMEM macro into a static function Benny Halevy
2009-08-12 20:36 ` Trond Myklebust
2009-08-12 15:22 ` [PATCH RFC 13/13] nfs: nfs4xdr: get rid of READ_BUF Benny Halevy
2009-08-12 21:05 ` Trond Myklebust
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=4AAD1A48.1040801@panasas.com \
--to=bhalevy@panasas.com \
--cc=Trond.Myklebust@netapp.com \
--cc=linux-nfs@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.