diff options
author | Alex Elder <elder@inktank.com> | 2013-03-29 15:28:03 -0400 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-05-02 00:17:41 -0400 |
commit | 0baa1bd9b6da7161dc1773b1dfce3adfd37d675f (patch) | |
tree | 30986227e5b5bdc0884066015ad78a3ce04bc79c /net/ceph | |
parent | 56fc5659162965ce3018a34c6bb8a022f3a3b33c (diff) |
libceph: be explicit in masking bottom 16 bits
In ceph_osdc_build_request() there is a call to cpu_to_le16() which
provides a 64-bit value as its argument. Because of the implied
byte swapping going on it looked pretty suspect to me.
At the moment it turns out the behavior is well defined, but masking
off those bottom bits explicitly eliminates this distraction, and is
in fact more directly related to the purpose of the message header's
data_off field.
This resolves:
http://tracker.ceph.com/issues/4125
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'net/ceph')
-rw-r--r-- | net/ceph/osd_client.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 3b6657fe99b1..015bf9f64da7 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c | |||
@@ -419,8 +419,18 @@ void ceph_osdc_build_request(struct ceph_osd_request *req, | |||
419 | p += 4; | 419 | p += 4; |
420 | 420 | ||
421 | /* data */ | 421 | /* data */ |
422 | if (flags & CEPH_OSD_FLAG_WRITE) | 422 | if (flags & CEPH_OSD_FLAG_WRITE) { |
423 | req->r_request->hdr.data_off = cpu_to_le16(off); | 423 | u16 data_off; |
424 | |||
425 | /* | ||
426 | * The header "data_off" is a hint to the receiver | ||
427 | * allowing it to align received data into its | ||
428 | * buffers such that there's no need to re-copy | ||
429 | * it before writing it to disk (direct I/O). | ||
430 | */ | ||
431 | data_off = (u16) (off & 0xffff); | ||
432 | req->r_request->hdr.data_off = cpu_to_le16(data_off); | ||
433 | } | ||
424 | req->r_request->hdr.data_len = cpu_to_le32(data_len); | 434 | req->r_request->hdr.data_len = cpu_to_le32(data_len); |
425 | 435 | ||
426 | BUG_ON(p > msg->front.iov_base + msg->front.iov_len); | 436 | BUG_ON(p > msg->front.iov_base + msg->front.iov_len); |