Skip to contentSkip to conversation

libceph: fix byte order mismatch

PATCH In review Alex Elder 2 participants 2 messages Apr 21, 2013 – Apr 22, 2013 Ceph common code (libceph)

lore
Share & tools
lore

Alex Elder

author
#0 lore raw

PATCH 1/1 libceph: fix byte order mismatch

A WATCH op includes an object version. The version that's supplied is incorrectly byte-swapped osd_req_op_watch_init() where it's first assigned (it's been this way since that code was first added).

The result is that the version sent to the osd is wrong, because that value gets byte-swapped again in osd_req_encode_op(). This is the source of a sparse warning related to improper byte order in the assignment.

The approach of using the version to avoid a race is deprecated (see http://tracker.ceph.com/issues/3871), and the watch parameter is no longer even examined by the osd. So fix the assignment in osd_req_op_watch_init() so it no longer does the byte swap.

This resolves:

    http://tracker.ceph.com/issues/3847
---
 net/ceph/osd_client.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/ceph/osd_client.c +0 -0
index 467020c..57d8db5 100644
@@ -577,8 +577,7 @@ void osd_req_op_watch_init(struct ceph_osd_request

*osd_req,
BUG_ON(opcode != CEPH_OSD_OP_NOTIFY_ACK && opcode != CEPH_OSD_OP_WATCH);

op->watch.cookie = cookie;
- /* op->watch.ver = version; */ /* XXX 3847 */
- op->watch.ver = cpu_to_le64(version);
+ op->watch.ver = version;
if (opcode == CEPH_OSD_OP_WATCH && flag)
op->watch.flag = (u8)1;
}

Signature · 1 line
1.7.9.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Alex Elder

A WATCH op includes an object version. The version that's supplied is incorrectly byte-swapped osd_req_op_watch_init() where it's first assigned (it's been this way since that code was first added).

The result is that the version sent to the osd is wrong, because that value gets byte-swapped again in osd_req_encode_op(). This is the source of a sparse warning related to improper byte order in the assignment.

Quoted 4 lines

The approach of using the version to avoid a race is deprecated (see http://tracker.ceph.com/issues/3871), and the watch parameter is no longer even examined by the osd. So fix the assignment in osd_req_op_watch_init() so it no longer does the byte swap.

IIRC it was never examined by the osd. Doesn't hurt to fix the encoding though.

Quoted 24 lines

This resolves:

     http://tracker.ceph.com/issues/3847
---
  net/ceph/osd_client.c |    3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
net/ceph/osd_client.c +1 -2
index 467020c..57d8db5 100644
@@ -577,8 +577,7 @@ void osd_req_op_watch_init(struct ceph_osd_request
 *osd_req,
  	BUG_ON(opcode != CEPH_OSD_OP_NOTIFY_ACK && opcode != CEPH_OSD_OP_WATCH);
 
  	op->watch.cookie = cookie;
-	/* op->watch.ver = version; */	/* XXX 3847 */
-	op->watch.ver = cpu_to_le64(version);
+	op->watch.ver = version;
  	if (opcode == CEPH_OSD_OP_WATCH && flag)
  		op->watch.flag = (u8)1;
  }