diff options
author | Yehuda Sadeh <yehuda@hq.newdream.net> | 2010-02-01 19:10:45 -0500 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2010-02-02 19:29:50 -0500 |
commit | 0c948992a00d478c17042f4790b7d6b35299cf94 (patch) | |
tree | 8a6bdfabcaf9f524fcfa6ce2ec10ebb73df0a9aa /fs/ceph | |
parent | 0f26c4b21b684825a6dd41f2bc04d48ff62d72f8 (diff) |
ceph: always send truncation info with read and write osd ops
This fixes a bug where the read/write ops arrive the osd after
a following truncation request.
Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net>
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph')
-rw-r--r-- | fs/ceph/ceph_fs.h | 2 | ||||
-rw-r--r-- | fs/ceph/osd_client.c | 16 | ||||
-rw-r--r-- | fs/ceph/rados.h | 6 |
3 files changed, 6 insertions, 18 deletions
diff --git a/fs/ceph/ceph_fs.h b/fs/ceph/ceph_fs.h index f3bfc3c4f6e6..004aae59d4ba 100644 --- a/fs/ceph/ceph_fs.h +++ b/fs/ceph/ceph_fs.h | |||
@@ -38,7 +38,7 @@ | |||
38 | #define CEPH_OSD_PROTOCOL 8 /* cluster internal */ | 38 | #define CEPH_OSD_PROTOCOL 8 /* cluster internal */ |
39 | #define CEPH_MDS_PROTOCOL 9 /* cluster internal */ | 39 | #define CEPH_MDS_PROTOCOL 9 /* cluster internal */ |
40 | #define CEPH_MON_PROTOCOL 5 /* cluster internal */ | 40 | #define CEPH_MON_PROTOCOL 5 /* cluster internal */ |
41 | #define CEPH_OSDC_PROTOCOL 23 /* server/client */ | 41 | #define CEPH_OSDC_PROTOCOL 24 /* server/client */ |
42 | #define CEPH_MDSC_PROTOCOL 32 /* server/client */ | 42 | #define CEPH_MDSC_PROTOCOL 32 /* server/client */ |
43 | #define CEPH_MONC_PROTOCOL 15 /* server/client */ | 43 | #define CEPH_MONC_PROTOCOL 15 /* server/client */ |
44 | 44 | ||
diff --git a/fs/ceph/osd_client.c b/fs/ceph/osd_client.c index df2106839713..944759b3079f 100644 --- a/fs/ceph/osd_client.c +++ b/fs/ceph/osd_client.c | |||
@@ -199,11 +199,9 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, | |||
199 | struct ceph_osd_request_head *head; | 199 | struct ceph_osd_request_head *head; |
200 | struct ceph_osd_op *op; | 200 | struct ceph_osd_op *op; |
201 | void *p; | 201 | void *p; |
202 | int do_trunc = truncate_seq && (off + *plen > truncate_size); | 202 | int num_op = 1 + do_sync; |
203 | int num_op = 1 + do_sync + do_trunc; | ||
204 | size_t msg_size = sizeof(*head) + num_op*sizeof(*op); | 203 | size_t msg_size = sizeof(*head) + num_op*sizeof(*op); |
205 | int err, i; | 204 | int err, i; |
206 | u64 prevofs; | ||
207 | 205 | ||
208 | if (use_mempool) { | 206 | if (use_mempool) { |
209 | req = mempool_alloc(osdc->req_mempool, GFP_NOFS); | 207 | req = mempool_alloc(osdc->req_mempool, GFP_NOFS); |
@@ -268,22 +266,14 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, | |||
268 | req->r_request->hdr.data_len = cpu_to_le32(*plen); | 266 | req->r_request->hdr.data_len = cpu_to_le32(*plen); |
269 | op->payload_len = cpu_to_le32(*plen); | 267 | op->payload_len = cpu_to_le32(*plen); |
270 | } | 268 | } |
269 | op->extent.truncate_size = cpu_to_le64(truncate_size); | ||
270 | op->extent.truncate_seq = cpu_to_le32(truncate_seq); | ||
271 | 271 | ||
272 | /* fill in oid */ | 272 | /* fill in oid */ |
273 | head->object_len = cpu_to_le32(req->r_oid_len); | 273 | head->object_len = cpu_to_le32(req->r_oid_len); |
274 | memcpy(p, req->r_oid, req->r_oid_len); | 274 | memcpy(p, req->r_oid, req->r_oid_len); |
275 | p += req->r_oid_len; | 275 | p += req->r_oid_len; |
276 | 276 | ||
277 | /* additional ops */ | ||
278 | if (do_trunc) { | ||
279 | op++; | ||
280 | op->op = cpu_to_le16(opcode == CEPH_OSD_OP_READ ? | ||
281 | CEPH_OSD_OP_MASKTRUNC : CEPH_OSD_OP_SETTRUNC); | ||
282 | op->trunc.truncate_seq = cpu_to_le32(truncate_seq); | ||
283 | prevofs = le64_to_cpu((op-1)->extent.offset); | ||
284 | op->trunc.truncate_size = cpu_to_le64(truncate_size - | ||
285 | (off-prevofs)); | ||
286 | } | ||
287 | if (do_sync) { | 277 | if (do_sync) { |
288 | op++; | 278 | op++; |
289 | op->op = cpu_to_le16(CEPH_OSD_OP_STARTSYNC); | 279 | op->op = cpu_to_le16(CEPH_OSD_OP_STARTSYNC); |
diff --git a/fs/ceph/rados.h b/fs/ceph/rados.h index c5614d4ae34a..123fd845459e 100644 --- a/fs/ceph/rados.h +++ b/fs/ceph/rados.h | |||
@@ -304,16 +304,14 @@ struct ceph_osd_op { | |||
304 | union { | 304 | union { |
305 | struct { | 305 | struct { |
306 | __le64 offset, length; | 306 | __le64 offset, length; |
307 | __le64 truncate_size; | ||
308 | __le32 truncate_seq; | ||
307 | } __attribute__ ((packed)) extent; | 309 | } __attribute__ ((packed)) extent; |
308 | struct { | 310 | struct { |
309 | __le32 name_len; | 311 | __le32 name_len; |
310 | __le32 value_len; | 312 | __le32 value_len; |
311 | } __attribute__ ((packed)) xattr; | 313 | } __attribute__ ((packed)) xattr; |
312 | struct { | 314 | struct { |
313 | __le64 truncate_size; | ||
314 | __le32 truncate_seq; | ||
315 | } __attribute__ ((packed)) trunc; | ||
316 | struct { | ||
317 | __u8 class_len; | 315 | __u8 class_len; |
318 | __u8 method_len; | 316 | __u8 method_len; |
319 | __u8 argc; | 317 | __u8 argc; |