layout->fl_pg_pool = cpu_to_le32((u32) pool_id);
}
+int rbd_calc_raw_layout(struct ceph_file_layout *layout,
+ u64 off, u64 *plen, u64 *bno,
+ struct ceph_osd_request *req,
+ struct ceph_osd_req_op *op)
+{
+ u64 orig_len = *plen;
+ u64 objoff, objlen; /* extent in object */
+ int r;
+
+ /* object extent? */
+ r = ceph_calc_file_object_mapping(layout, off, orig_len, bno,
+ &objoff, &objlen);
+ if (r < 0)
+ return r;
+ if (objlen < orig_len) {
+ *plen = objlen;
+ dout(" skipping last %llu, final file extent %llu~%llu\n",
+ orig_len - *plen, off, *plen);
+ }
+
+ if (op->op == CEPH_OSD_OP_READ || op->op == CEPH_OSD_OP_WRITE) {
+ op->extent.offset = objoff;
+ op->extent.length = objlen;
+ }
+ req->r_num_pages = calc_pages_for(off, *plen);
+ req->r_page_alignment = off & ~PAGE_MASK;
+ if (op->op == CEPH_OSD_OP_WRITE)
+ op->payload_len = *plen;
+
+ dout("calc_layout bno=%llx %llu~%llu (%d pages)\n",
+ *bno, objoff, objlen, req->r_num_pages);
+ return 0;
+}
+
/*
* Send ceph osd request
*/
osd_req->r_oid_len = strlen(osd_req->r_oid);
rbd_layout_init(&osd_req->r_file_layout, rbd_dev->spec->pool_id);
- ret = ceph_calc_raw_layout(&osd_req->r_file_layout,
+ ret = rbd_calc_raw_layout(&osd_req->r_file_layout,
ofs, &len, &bno, osd_req, op);
rbd_assert(ret == 0);