Lines Matching refs:obj_req

644 static void rbd_obj_handle_request(struct rbd_obj_request *obj_req, int result);
1310 static void rbd_obj_zero_range(struct rbd_obj_request *obj_req, u32 off, in rbd_obj_zero_range() argument
1313 dout("%s %p data buf %u~%u\n", __func__, obj_req, off, bytes); in rbd_obj_zero_range()
1315 switch (obj_req->img_request->data_type) { in rbd_obj_zero_range()
1317 zero_bios(&obj_req->bio_pos, off, bytes); in rbd_obj_zero_range()
1321 zero_bvecs(&obj_req->bvec_pos, off, bytes); in rbd_obj_zero_range()
1358 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_submit() local
1361 __func__, osd_req, obj_req, obj_req->ex.oe_objno, in rbd_osd_submit()
1362 obj_req->ex.oe_off, obj_req->ex.oe_len); in rbd_osd_submit()
1381 static bool rbd_obj_is_entire(struct rbd_obj_request *obj_req) in rbd_obj_is_entire() argument
1383 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_is_entire()
1385 return !obj_req->ex.oe_off && in rbd_obj_is_entire()
1386 obj_req->ex.oe_len == rbd_dev->layout.object_size; in rbd_obj_is_entire()
1389 static bool rbd_obj_is_tail(struct rbd_obj_request *obj_req) in rbd_obj_is_tail() argument
1391 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_is_tail()
1393 return obj_req->ex.oe_off + obj_req->ex.oe_len == in rbd_obj_is_tail()
1400 static bool rbd_obj_copyup_enabled(struct rbd_obj_request *obj_req) in rbd_obj_copyup_enabled() argument
1402 if (!obj_req->num_img_extents || in rbd_obj_copyup_enabled()
1403 (rbd_obj_is_entire(obj_req) && in rbd_obj_copyup_enabled()
1404 !obj_req->img_request->snapc->num_snaps)) in rbd_obj_copyup_enabled()
1410 static u64 rbd_obj_img_extents_bytes(struct rbd_obj_request *obj_req) in rbd_obj_img_extents_bytes() argument
1412 return ceph_file_extents_bytes(obj_req->img_extents, in rbd_obj_img_extents_bytes()
1413 obj_req->num_img_extents); in rbd_obj_img_extents_bytes()
1432 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_req_callback() local
1436 osd_req->r_result, obj_req); in rbd_osd_req_callback()
1443 if (osd_req->r_result > 0 && rbd_img_is_write(obj_req->img_request)) in rbd_osd_req_callback()
1448 rbd_obj_handle_request(obj_req, result); in rbd_osd_req_callback()
1471 __rbd_obj_add_osd_request(struct rbd_obj_request *obj_req, in __rbd_obj_add_osd_request() argument
1474 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in __rbd_obj_add_osd_request()
1485 list_add_tail(&req->r_private_item, &obj_req->osd_reqs); in __rbd_obj_add_osd_request()
1487 req->r_priv = obj_req; in __rbd_obj_add_osd_request()
1498 obj_req->ex.oe_objno); in __rbd_obj_add_osd_request()
1506 rbd_obj_add_osd_request(struct rbd_obj_request *obj_req, int num_ops) in rbd_obj_add_osd_request() argument
1508 return __rbd_obj_add_osd_request(obj_req, obj_req->img_request->snapc, in rbd_obj_add_osd_request()
1990 static int rbd_object_map_update_finish(struct rbd_obj_request *obj_req, in rbd_object_map_update_finish() argument
1993 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_object_map_update_finish()
2018 rbd_assert(objno == obj_req->ex.oe_objno); in rbd_object_map_update_finish()
2037 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_object_map_callback() local
2041 osd_req->r_result, obj_req); in rbd_object_map_callback()
2043 result = rbd_object_map_update_finish(obj_req, osd_req); in rbd_object_map_callback()
2044 rbd_obj_handle_request(obj_req, result); in rbd_object_map_callback()
2097 static int rbd_object_map_update(struct rbd_obj_request *obj_req, u64 snap_id, in rbd_object_map_update() argument
2100 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_object_map_update()
2108 if (!update_needed(rbd_dev, obj_req->ex.oe_objno, new_state)) in rbd_object_map_update()
2118 list_add_tail(&req->r_private_item, &obj_req->osd_reqs); in rbd_object_map_update()
2120 req->r_priv = obj_req; in rbd_object_map_update()
2138 ret = rbd_cls_object_map_update(req, which, obj_req->ex.oe_objno, in rbd_object_map_update()
2175 static int rbd_obj_calc_img_extents(struct rbd_obj_request *obj_req, in rbd_obj_calc_img_extents() argument
2178 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_calc_img_extents()
2184 ret = ceph_extent_to_file(&rbd_dev->layout, obj_req->ex.oe_objno, in rbd_obj_calc_img_extents()
2185 entire ? 0 : obj_req->ex.oe_off, in rbd_obj_calc_img_extents()
2187 obj_req->ex.oe_len, in rbd_obj_calc_img_extents()
2188 &obj_req->img_extents, in rbd_obj_calc_img_extents()
2189 &obj_req->num_img_extents); in rbd_obj_calc_img_extents()
2193 prune_extents(obj_req->img_extents, &obj_req->num_img_extents, in rbd_obj_calc_img_extents()
2200 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_setup_data() local
2202 switch (obj_req->img_request->data_type) { in rbd_osd_setup_data()
2205 &obj_req->bio_pos, in rbd_osd_setup_data()
2206 obj_req->ex.oe_len); in rbd_osd_setup_data()
2210 rbd_assert(obj_req->bvec_pos.iter.bi_size == in rbd_osd_setup_data()
2211 obj_req->ex.oe_len); in rbd_osd_setup_data()
2212 rbd_assert(obj_req->bvec_idx == obj_req->bvec_count); in rbd_osd_setup_data()
2214 &obj_req->bvec_pos); in rbd_osd_setup_data()
2247 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_setup_copyup() local
2254 osd_req_op_cls_request_data_bvecs(osd_req, which, obj_req->copyup_bvecs, in rbd_osd_setup_copyup()
2255 obj_req->copyup_bvec_count, bytes); in rbd_osd_setup_copyup()
2259 static int rbd_obj_init_read(struct rbd_obj_request *obj_req) in rbd_obj_init_read() argument
2261 obj_req->read_state = RBD_OBJ_READ_START; in rbd_obj_init_read()
2268 struct rbd_obj_request *obj_req = osd_req->r_priv; in __rbd_osd_setup_write_ops() local
2269 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in __rbd_osd_setup_write_ops()
2273 !(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST)) { in __rbd_osd_setup_write_ops()
2280 if (rbd_obj_is_entire(obj_req)) in __rbd_osd_setup_write_ops()
2286 obj_req->ex.oe_off, obj_req->ex.oe_len, 0, 0); in __rbd_osd_setup_write_ops()
2290 static int rbd_obj_init_write(struct rbd_obj_request *obj_req) in rbd_obj_init_write() argument
2295 ret = rbd_obj_calc_img_extents(obj_req, true); in rbd_obj_init_write()
2299 if (rbd_obj_copyup_enabled(obj_req)) in rbd_obj_init_write()
2300 obj_req->flags |= RBD_OBJ_FLAG_COPYUP_ENABLED; in rbd_obj_init_write()
2302 obj_req->write_state = RBD_OBJ_WRITE_START; in rbd_obj_init_write()
2306 static u16 truncate_or_zero_opcode(struct rbd_obj_request *obj_req) in truncate_or_zero_opcode() argument
2308 return rbd_obj_is_tail(obj_req) ? CEPH_OSD_OP_TRUNCATE : in truncate_or_zero_opcode()
2315 struct rbd_obj_request *obj_req = osd_req->r_priv; in __rbd_osd_setup_discard_ops() local
2317 if (rbd_obj_is_entire(obj_req) && !obj_req->num_img_extents) { in __rbd_osd_setup_discard_ops()
2318 rbd_assert(obj_req->flags & RBD_OBJ_FLAG_DELETION); in __rbd_osd_setup_discard_ops()
2322 truncate_or_zero_opcode(obj_req), in __rbd_osd_setup_discard_ops()
2323 obj_req->ex.oe_off, obj_req->ex.oe_len, in __rbd_osd_setup_discard_ops()
2328 static int rbd_obj_init_discard(struct rbd_obj_request *obj_req) in rbd_obj_init_discard() argument
2330 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_init_discard()
2343 !rbd_obj_is_tail(obj_req)) { in rbd_obj_init_discard()
2344 off = round_up(obj_req->ex.oe_off, rbd_dev->opts->alloc_size); in rbd_obj_init_discard()
2345 next_off = round_down(obj_req->ex.oe_off + obj_req->ex.oe_len, in rbd_obj_init_discard()
2351 obj_req, obj_req->ex.oe_off, obj_req->ex.oe_len, in rbd_obj_init_discard()
2353 obj_req->ex.oe_off = off; in rbd_obj_init_discard()
2354 obj_req->ex.oe_len = next_off - off; in rbd_obj_init_discard()
2358 ret = rbd_obj_calc_img_extents(obj_req, true); in rbd_obj_init_discard()
2362 obj_req->flags |= RBD_OBJ_FLAG_NOOP_FOR_NONEXISTENT; in rbd_obj_init_discard()
2363 if (rbd_obj_is_entire(obj_req) && !obj_req->num_img_extents) in rbd_obj_init_discard()
2364 obj_req->flags |= RBD_OBJ_FLAG_DELETION; in rbd_obj_init_discard()
2366 obj_req->write_state = RBD_OBJ_WRITE_START; in rbd_obj_init_discard()
2373 struct rbd_obj_request *obj_req = osd_req->r_priv; in __rbd_osd_setup_zeroout_ops() local
2376 if (rbd_obj_is_entire(obj_req)) { in __rbd_osd_setup_zeroout_ops()
2377 if (obj_req->num_img_extents) { in __rbd_osd_setup_zeroout_ops()
2378 if (!(obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED)) in __rbd_osd_setup_zeroout_ops()
2383 rbd_assert(obj_req->flags & RBD_OBJ_FLAG_DELETION); in __rbd_osd_setup_zeroout_ops()
2389 opcode = truncate_or_zero_opcode(obj_req); in __rbd_osd_setup_zeroout_ops()
2394 obj_req->ex.oe_off, obj_req->ex.oe_len, in __rbd_osd_setup_zeroout_ops()
2398 static int rbd_obj_init_zeroout(struct rbd_obj_request *obj_req) in rbd_obj_init_zeroout() argument
2403 ret = rbd_obj_calc_img_extents(obj_req, true); in rbd_obj_init_zeroout()
2407 if (rbd_obj_copyup_enabled(obj_req)) in rbd_obj_init_zeroout()
2408 obj_req->flags |= RBD_OBJ_FLAG_COPYUP_ENABLED; in rbd_obj_init_zeroout()
2409 if (!obj_req->num_img_extents) { in rbd_obj_init_zeroout()
2410 obj_req->flags |= RBD_OBJ_FLAG_NOOP_FOR_NONEXISTENT; in rbd_obj_init_zeroout()
2411 if (rbd_obj_is_entire(obj_req)) in rbd_obj_init_zeroout()
2412 obj_req->flags |= RBD_OBJ_FLAG_DELETION; in rbd_obj_init_zeroout()
2415 obj_req->write_state = RBD_OBJ_WRITE_START; in rbd_obj_init_zeroout()
2419 static int count_write_ops(struct rbd_obj_request *obj_req) in count_write_ops() argument
2421 struct rbd_img_request *img_req = obj_req->img_request; in count_write_ops()
2426 !(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST)) in count_write_ops()
2433 if (rbd_obj_is_entire(obj_req) && obj_req->num_img_extents && in count_write_ops()
2434 !(obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED)) in count_write_ops()
2446 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_setup_write_ops() local
2448 switch (obj_req->img_request->op_type) { in rbd_osd_setup_write_ops()
2470 struct rbd_obj_request *obj_req, *next_obj_req; in __rbd_img_fill_request() local
2473 for_each_obj_request_safe(img_req, obj_req, next_obj_req) { in __rbd_img_fill_request()
2476 ret = rbd_obj_init_read(obj_req); in __rbd_img_fill_request()
2479 ret = rbd_obj_init_write(obj_req); in __rbd_img_fill_request()
2482 ret = rbd_obj_init_discard(obj_req); in __rbd_img_fill_request()
2485 ret = rbd_obj_init_zeroout(obj_req); in __rbd_img_fill_request()
2493 rbd_img_obj_request_del(img_req, obj_req); in __rbd_img_fill_request()
2519 struct rbd_obj_request *obj_req; in alloc_object_extent() local
2521 obj_req = rbd_obj_request_create(); in alloc_object_extent()
2522 if (!obj_req) in alloc_object_extent()
2525 rbd_img_obj_request_add(img_req, obj_req); in alloc_object_extent()
2526 return &obj_req->ex; in alloc_object_extent()
2589 struct rbd_obj_request *obj_req; in rbd_img_fill_request() local
2619 for_each_obj_request(img_req, obj_req) { in rbd_img_fill_request()
2620 obj_req->bvec_pos.bvecs = kmalloc_array(obj_req->bvec_count, in rbd_img_fill_request()
2621 sizeof(*obj_req->bvec_pos.bvecs), in rbd_img_fill_request()
2623 if (!obj_req->bvec_pos.bvecs) in rbd_img_fill_request()
2660 struct rbd_obj_request *obj_req = in set_bio_pos() local
2665 obj_req->bio_pos = *it; in set_bio_pos()
2671 struct rbd_obj_request *obj_req = in count_bio_bvecs() local
2677 obj_req->bvec_count++; in count_bio_bvecs()
2684 struct rbd_obj_request *obj_req = in copy_bio_bvecs() local
2690 obj_req->bvec_pos.bvecs[obj_req->bvec_idx++] = bv; in copy_bio_bvecs()
2691 obj_req->bvec_pos.iter.bi_size += bv.bv_len; in copy_bio_bvecs()
2723 struct rbd_obj_request *obj_req = in set_bvec_pos() local
2727 obj_req->bvec_pos = *it; in set_bvec_pos()
2728 ceph_bvec_iter_shorten(&obj_req->bvec_pos, bytes); in set_bvec_pos()
2734 struct rbd_obj_request *obj_req = in count_bvecs() local
2739 obj_req->bvec_count++; in count_bvecs()
2745 struct rbd_obj_request *obj_req = in copy_bvecs() local
2750 obj_req->bvec_pos.bvecs[obj_req->bvec_idx++] = bv; in copy_bvecs()
2751 obj_req->bvec_pos.iter.bi_size += bv.bv_len; in copy_bvecs()
2802 static bool rbd_obj_may_exist(struct rbd_obj_request *obj_req) in rbd_obj_may_exist() argument
2804 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_may_exist()
2806 if (rbd_object_map_may_exist(rbd_dev, obj_req->ex.oe_objno)) { in rbd_obj_may_exist()
2807 obj_req->flags |= RBD_OBJ_FLAG_MAY_EXIST; in rbd_obj_may_exist()
2811 dout("%s %p objno %llu assuming dne\n", __func__, obj_req, in rbd_obj_may_exist()
2812 obj_req->ex.oe_objno); in rbd_obj_may_exist()
2816 static int rbd_obj_read_object(struct rbd_obj_request *obj_req) in rbd_obj_read_object() argument
2821 osd_req = __rbd_obj_add_osd_request(obj_req, NULL, 1); in rbd_obj_read_object()
2826 obj_req->ex.oe_off, obj_req->ex.oe_len, 0, 0); in rbd_obj_read_object()
2838 static int rbd_obj_read_from_parent(struct rbd_obj_request *obj_req) in rbd_obj_read_from_parent() argument
2840 struct rbd_img_request *img_req = obj_req->img_request; in rbd_obj_read_from_parent()
2851 child_img_req->obj_request = obj_req; in rbd_obj_read_from_parent()
2858 obj_req); in rbd_obj_read_from_parent()
2864 obj_req->img_extents, in rbd_obj_read_from_parent()
2865 obj_req->num_img_extents, in rbd_obj_read_from_parent()
2866 &obj_req->bio_pos); in rbd_obj_read_from_parent()
2871 obj_req->img_extents, in rbd_obj_read_from_parent()
2872 obj_req->num_img_extents, in rbd_obj_read_from_parent()
2873 &obj_req->bvec_pos); in rbd_obj_read_from_parent()
2880 obj_req->img_extents, in rbd_obj_read_from_parent()
2881 obj_req->num_img_extents, in rbd_obj_read_from_parent()
2882 obj_req->copyup_bvecs); in rbd_obj_read_from_parent()
2894 static bool rbd_obj_advance_read(struct rbd_obj_request *obj_req, int *result) in rbd_obj_advance_read() argument
2896 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_advance_read()
2900 switch (obj_req->read_state) { in rbd_obj_advance_read()
2904 if (!rbd_obj_may_exist(obj_req)) { in rbd_obj_advance_read()
2906 obj_req->read_state = RBD_OBJ_READ_OBJECT; in rbd_obj_advance_read()
2910 ret = rbd_obj_read_object(obj_req); in rbd_obj_advance_read()
2915 obj_req->read_state = RBD_OBJ_READ_OBJECT; in rbd_obj_advance_read()
2920 ret = rbd_obj_calc_img_extents(obj_req, false); in rbd_obj_advance_read()
2925 if (obj_req->num_img_extents) { in rbd_obj_advance_read()
2926 ret = rbd_obj_read_from_parent(obj_req); in rbd_obj_advance_read()
2931 obj_req->read_state = RBD_OBJ_READ_PARENT; in rbd_obj_advance_read()
2942 rbd_obj_zero_range(obj_req, 0, obj_req->ex.oe_len); in rbd_obj_advance_read()
2945 if (*result < obj_req->ex.oe_len) in rbd_obj_advance_read()
2946 rbd_obj_zero_range(obj_req, *result, in rbd_obj_advance_read()
2947 obj_req->ex.oe_len - *result); in rbd_obj_advance_read()
2949 rbd_assert(*result == obj_req->ex.oe_len); in rbd_obj_advance_read()
2959 u32 obj_overlap = rbd_obj_img_extents_bytes(obj_req); in rbd_obj_advance_read()
2961 if (obj_overlap < obj_req->ex.oe_len) in rbd_obj_advance_read()
2962 rbd_obj_zero_range(obj_req, obj_overlap, in rbd_obj_advance_read()
2963 obj_req->ex.oe_len - obj_overlap); in rbd_obj_advance_read()
2971 static bool rbd_obj_write_is_noop(struct rbd_obj_request *obj_req) in rbd_obj_write_is_noop() argument
2973 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_write_is_noop()
2975 if (rbd_object_map_may_exist(rbd_dev, obj_req->ex.oe_objno)) in rbd_obj_write_is_noop()
2976 obj_req->flags |= RBD_OBJ_FLAG_MAY_EXIST; in rbd_obj_write_is_noop()
2978 if (!(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST) && in rbd_obj_write_is_noop()
2979 (obj_req->flags & RBD_OBJ_FLAG_NOOP_FOR_NONEXISTENT)) { in rbd_obj_write_is_noop()
2980 dout("%s %p noop for nonexistent\n", __func__, obj_req); in rbd_obj_write_is_noop()
2993 static int rbd_obj_write_pre_object_map(struct rbd_obj_request *obj_req) in rbd_obj_write_pre_object_map() argument
2995 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_write_pre_object_map()
3001 if (obj_req->flags & RBD_OBJ_FLAG_DELETION) in rbd_obj_write_pre_object_map()
3006 return rbd_object_map_update(obj_req, CEPH_NOSNAP, new_state, NULL); in rbd_obj_write_pre_object_map()
3009 static int rbd_obj_write_object(struct rbd_obj_request *obj_req) in rbd_obj_write_object() argument
3012 int num_ops = count_write_ops(obj_req); in rbd_obj_write_object()
3016 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED) in rbd_obj_write_object()
3019 osd_req = rbd_obj_add_osd_request(obj_req, num_ops); in rbd_obj_write_object()
3023 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED) { in rbd_obj_write_object()
3060 static int rbd_obj_copyup_empty_snapc(struct rbd_obj_request *obj_req, in rbd_obj_copyup_empty_snapc() argument
3066 dout("%s obj_req %p bytes %u\n", __func__, obj_req, bytes); in rbd_obj_copyup_empty_snapc()
3069 osd_req = __rbd_obj_add_osd_request(obj_req, &rbd_empty_snapc, 1); in rbd_obj_copyup_empty_snapc()
3087 static int rbd_obj_copyup_current_snapc(struct rbd_obj_request *obj_req, in rbd_obj_copyup_current_snapc() argument
3091 int num_ops = count_write_ops(obj_req); in rbd_obj_copyup_current_snapc()
3095 dout("%s obj_req %p bytes %u\n", __func__, obj_req, bytes); in rbd_obj_copyup_current_snapc()
3100 osd_req = rbd_obj_add_osd_request(obj_req, num_ops); in rbd_obj_copyup_current_snapc()
3121 static int setup_copyup_bvecs(struct rbd_obj_request *obj_req, u64 obj_overlap) in setup_copyup_bvecs() argument
3125 rbd_assert(!obj_req->copyup_bvecs); in setup_copyup_bvecs()
3126 obj_req->copyup_bvec_count = calc_pages_for(0, obj_overlap); in setup_copyup_bvecs()
3127 obj_req->copyup_bvecs = kcalloc(obj_req->copyup_bvec_count, in setup_copyup_bvecs()
3128 sizeof(*obj_req->copyup_bvecs), in setup_copyup_bvecs()
3130 if (!obj_req->copyup_bvecs) in setup_copyup_bvecs()
3133 for (i = 0; i < obj_req->copyup_bvec_count; i++) { in setup_copyup_bvecs()
3136 obj_req->copyup_bvecs[i].bv_page = alloc_page(GFP_NOIO); in setup_copyup_bvecs()
3137 if (!obj_req->copyup_bvecs[i].bv_page) in setup_copyup_bvecs()
3140 obj_req->copyup_bvecs[i].bv_offset = 0; in setup_copyup_bvecs()
3141 obj_req->copyup_bvecs[i].bv_len = len; in setup_copyup_bvecs()
3154 static int rbd_obj_copyup_read_parent(struct rbd_obj_request *obj_req) in rbd_obj_copyup_read_parent() argument
3156 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_copyup_read_parent()
3159 rbd_assert(obj_req->num_img_extents); in rbd_obj_copyup_read_parent()
3160 prune_extents(obj_req->img_extents, &obj_req->num_img_extents, in rbd_obj_copyup_read_parent()
3162 if (!obj_req->num_img_extents) { in rbd_obj_copyup_read_parent()
3169 return rbd_obj_copyup_current_snapc(obj_req, MODS_ONLY); in rbd_obj_copyup_read_parent()
3172 ret = setup_copyup_bvecs(obj_req, rbd_obj_img_extents_bytes(obj_req)); in rbd_obj_copyup_read_parent()
3176 return rbd_obj_read_from_parent(obj_req); in rbd_obj_copyup_read_parent()
3179 static void rbd_obj_copyup_object_maps(struct rbd_obj_request *obj_req) in rbd_obj_copyup_object_maps() argument
3181 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_copyup_object_maps()
3182 struct ceph_snap_context *snapc = obj_req->img_request->snapc; in rbd_obj_copyup_object_maps()
3187 rbd_assert(!obj_req->pending.result && !obj_req->pending.num_pending); in rbd_obj_copyup_object_maps()
3192 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ZEROS) in rbd_obj_copyup_object_maps()
3202 ret = rbd_object_map_update(obj_req, snapc->snaps[i], in rbd_obj_copyup_object_maps()
3205 obj_req->pending.result = ret; in rbd_obj_copyup_object_maps()
3210 obj_req->pending.num_pending++; in rbd_obj_copyup_object_maps()
3214 static void rbd_obj_copyup_write_object(struct rbd_obj_request *obj_req) in rbd_obj_copyup_write_object() argument
3216 u32 bytes = rbd_obj_img_extents_bytes(obj_req); in rbd_obj_copyup_write_object()
3219 rbd_assert(!obj_req->pending.result && !obj_req->pending.num_pending); in rbd_obj_copyup_write_object()
3226 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ZEROS) in rbd_obj_copyup_write_object()
3229 if (obj_req->img_request->snapc->num_snaps && bytes > 0) { in rbd_obj_copyup_write_object()
3236 ret = rbd_obj_copyup_empty_snapc(obj_req, bytes); in rbd_obj_copyup_write_object()
3238 obj_req->pending.result = ret; in rbd_obj_copyup_write_object()
3242 obj_req->pending.num_pending++; in rbd_obj_copyup_write_object()
3246 ret = rbd_obj_copyup_current_snapc(obj_req, bytes); in rbd_obj_copyup_write_object()
3248 obj_req->pending.result = ret; in rbd_obj_copyup_write_object()
3252 obj_req->pending.num_pending++; in rbd_obj_copyup_write_object()
3255 static bool rbd_obj_advance_copyup(struct rbd_obj_request *obj_req, int *result) in rbd_obj_advance_copyup() argument
3257 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_advance_copyup()
3261 switch (obj_req->copyup_state) { in rbd_obj_advance_copyup()
3265 ret = rbd_obj_copyup_read_parent(obj_req); in rbd_obj_advance_copyup()
3270 if (obj_req->num_img_extents) in rbd_obj_advance_copyup()
3271 obj_req->copyup_state = RBD_OBJ_COPYUP_READ_PARENT; in rbd_obj_advance_copyup()
3273 obj_req->copyup_state = RBD_OBJ_COPYUP_WRITE_OBJECT; in rbd_obj_advance_copyup()
3279 if (is_zero_bvecs(obj_req->copyup_bvecs, in rbd_obj_advance_copyup()
3280 rbd_obj_img_extents_bytes(obj_req))) { in rbd_obj_advance_copyup()
3281 dout("%s %p detected zeros\n", __func__, obj_req); in rbd_obj_advance_copyup()
3282 obj_req->flags |= RBD_OBJ_FLAG_COPYUP_ZEROS; in rbd_obj_advance_copyup()
3285 rbd_obj_copyup_object_maps(obj_req); in rbd_obj_advance_copyup()
3286 if (!obj_req->pending.num_pending) { in rbd_obj_advance_copyup()
3287 *result = obj_req->pending.result; in rbd_obj_advance_copyup()
3288 obj_req->copyup_state = RBD_OBJ_COPYUP_OBJECT_MAPS; in rbd_obj_advance_copyup()
3291 obj_req->copyup_state = __RBD_OBJ_COPYUP_OBJECT_MAPS; in rbd_obj_advance_copyup()
3294 if (!pending_result_dec(&obj_req->pending, result)) in rbd_obj_advance_copyup()
3304 rbd_obj_copyup_write_object(obj_req); in rbd_obj_advance_copyup()
3305 if (!obj_req->pending.num_pending) { in rbd_obj_advance_copyup()
3306 *result = obj_req->pending.result; in rbd_obj_advance_copyup()
3307 obj_req->copyup_state = RBD_OBJ_COPYUP_WRITE_OBJECT; in rbd_obj_advance_copyup()
3310 obj_req->copyup_state = __RBD_OBJ_COPYUP_WRITE_OBJECT; in rbd_obj_advance_copyup()
3313 if (!pending_result_dec(&obj_req->pending, result)) in rbd_obj_advance_copyup()
3329 static int rbd_obj_write_post_object_map(struct rbd_obj_request *obj_req) in rbd_obj_write_post_object_map() argument
3331 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_write_post_object_map()
3337 if (!(obj_req->flags & RBD_OBJ_FLAG_DELETION)) in rbd_obj_write_post_object_map()
3340 return rbd_object_map_update(obj_req, CEPH_NOSNAP, OBJECT_NONEXISTENT, in rbd_obj_write_post_object_map()
3344 static bool rbd_obj_advance_write(struct rbd_obj_request *obj_req, int *result) in rbd_obj_advance_write() argument
3346 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_advance_write()
3350 switch (obj_req->write_state) { in rbd_obj_advance_write()
3354 if (rbd_obj_write_is_noop(obj_req)) in rbd_obj_advance_write()
3357 ret = rbd_obj_write_pre_object_map(obj_req); in rbd_obj_advance_write()
3362 obj_req->write_state = RBD_OBJ_WRITE_PRE_OBJECT_MAP; in rbd_obj_advance_write()
3372 ret = rbd_obj_write_object(obj_req); in rbd_obj_advance_write()
3377 obj_req->write_state = RBD_OBJ_WRITE_OBJECT; in rbd_obj_advance_write()
3381 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED) { in rbd_obj_advance_write()
3383 obj_req->copyup_state = RBD_OBJ_COPYUP_START; in rbd_obj_advance_write()
3384 obj_req->write_state = __RBD_OBJ_WRITE_COPYUP; in rbd_obj_advance_write()
3391 if (obj_req->flags & RBD_OBJ_FLAG_DELETION) in rbd_obj_advance_write()
3397 obj_req->write_state = RBD_OBJ_WRITE_COPYUP; in rbd_obj_advance_write()
3400 if (!rbd_obj_advance_copyup(obj_req, result)) in rbd_obj_advance_write()
3408 ret = rbd_obj_write_post_object_map(obj_req); in rbd_obj_advance_write()
3413 obj_req->write_state = RBD_OBJ_WRITE_POST_OBJECT_MAP; in rbd_obj_advance_write()
3430 static bool __rbd_obj_handle_request(struct rbd_obj_request *obj_req, in __rbd_obj_handle_request() argument
3433 struct rbd_img_request *img_req = obj_req->img_request; in __rbd_obj_handle_request()
3437 mutex_lock(&obj_req->state_mutex); in __rbd_obj_handle_request()
3439 done = rbd_obj_advance_read(obj_req, result); in __rbd_obj_handle_request()
3441 done = rbd_obj_advance_write(obj_req, result); in __rbd_obj_handle_request()
3442 mutex_unlock(&obj_req->state_mutex); in __rbd_obj_handle_request()
3447 obj_op_name(img_req->op_type), obj_req->ex.oe_objno, in __rbd_obj_handle_request()
3448 obj_req->ex.oe_off, obj_req->ex.oe_len, *result); in __rbd_obj_handle_request()
3457 static void rbd_obj_handle_request(struct rbd_obj_request *obj_req, int result) in rbd_obj_handle_request() argument
3459 if (__rbd_obj_handle_request(obj_req, &result)) in rbd_obj_handle_request()
3460 rbd_img_handle_request(obj_req->img_request, result); in rbd_obj_handle_request()
3540 struct rbd_obj_request *obj_req; in rbd_img_object_requests() local
3544 for_each_obj_request(img_req, obj_req) { in rbd_img_object_requests()
3547 if (__rbd_obj_handle_request(obj_req, &result)) { in rbd_img_object_requests()
3642 struct rbd_obj_request *obj_req = img_req->obj_request; in rbd_img_handle_request() local
3645 if (__rbd_obj_handle_request(obj_req, &result)) { in rbd_img_handle_request()
3646 img_req = obj_req->img_request; in rbd_img_handle_request()