Lines Matching refs:obj_req

644 static void rbd_obj_handle_request(struct rbd_obj_request *obj_req, int result);
1259 static void rbd_obj_zero_range(struct rbd_obj_request *obj_req, u32 off, in rbd_obj_zero_range() argument
1262 dout("%s %p data buf %u~%u\n", __func__, obj_req, off, bytes); in rbd_obj_zero_range()
1264 switch (obj_req->img_request->data_type) { in rbd_obj_zero_range()
1266 zero_bios(&obj_req->bio_pos, off, bytes); in rbd_obj_zero_range()
1270 zero_bvecs(&obj_req->bvec_pos, off, bytes); in rbd_obj_zero_range()
1307 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_submit() local
1310 __func__, osd_req, obj_req, obj_req->ex.oe_objno, in rbd_osd_submit()
1311 obj_req->ex.oe_off, obj_req->ex.oe_len); in rbd_osd_submit()
1330 static bool rbd_obj_is_entire(struct rbd_obj_request *obj_req) in rbd_obj_is_entire() argument
1332 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_is_entire()
1334 return !obj_req->ex.oe_off && in rbd_obj_is_entire()
1335 obj_req->ex.oe_len == rbd_dev->layout.object_size; in rbd_obj_is_entire()
1338 static bool rbd_obj_is_tail(struct rbd_obj_request *obj_req) in rbd_obj_is_tail() argument
1340 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_is_tail()
1342 return obj_req->ex.oe_off + obj_req->ex.oe_len == in rbd_obj_is_tail()
1349 static bool rbd_obj_copyup_enabled(struct rbd_obj_request *obj_req) in rbd_obj_copyup_enabled() argument
1351 if (!obj_req->num_img_extents || in rbd_obj_copyup_enabled()
1352 (rbd_obj_is_entire(obj_req) && in rbd_obj_copyup_enabled()
1353 !obj_req->img_request->snapc->num_snaps)) in rbd_obj_copyup_enabled()
1359 static u64 rbd_obj_img_extents_bytes(struct rbd_obj_request *obj_req) in rbd_obj_img_extents_bytes() argument
1361 return ceph_file_extents_bytes(obj_req->img_extents, in rbd_obj_img_extents_bytes()
1362 obj_req->num_img_extents); in rbd_obj_img_extents_bytes()
1381 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_req_callback() local
1385 osd_req->r_result, obj_req); in rbd_osd_req_callback()
1392 if (osd_req->r_result > 0 && rbd_img_is_write(obj_req->img_request)) in rbd_osd_req_callback()
1397 rbd_obj_handle_request(obj_req, result); in rbd_osd_req_callback()
1420 __rbd_obj_add_osd_request(struct rbd_obj_request *obj_req, in __rbd_obj_add_osd_request() argument
1423 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in __rbd_obj_add_osd_request()
1434 list_add_tail(&req->r_private_item, &obj_req->osd_reqs); in __rbd_obj_add_osd_request()
1436 req->r_priv = obj_req; in __rbd_obj_add_osd_request()
1447 obj_req->ex.oe_objno); in __rbd_obj_add_osd_request()
1455 rbd_obj_add_osd_request(struct rbd_obj_request *obj_req, int num_ops) in rbd_obj_add_osd_request() argument
1457 return __rbd_obj_add_osd_request(obj_req, obj_req->img_request->snapc, in rbd_obj_add_osd_request()
1939 static int rbd_object_map_update_finish(struct rbd_obj_request *obj_req, in rbd_object_map_update_finish() argument
1942 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_object_map_update_finish()
1967 rbd_assert(objno == obj_req->ex.oe_objno); in rbd_object_map_update_finish()
1986 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_object_map_callback() local
1990 osd_req->r_result, obj_req); in rbd_object_map_callback()
1992 result = rbd_object_map_update_finish(obj_req, osd_req); in rbd_object_map_callback()
1993 rbd_obj_handle_request(obj_req, result); in rbd_object_map_callback()
2046 static int rbd_object_map_update(struct rbd_obj_request *obj_req, u64 snap_id, in rbd_object_map_update() argument
2049 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_object_map_update()
2057 if (!update_needed(rbd_dev, obj_req->ex.oe_objno, new_state)) in rbd_object_map_update()
2067 list_add_tail(&req->r_private_item, &obj_req->osd_reqs); in rbd_object_map_update()
2069 req->r_priv = obj_req; in rbd_object_map_update()
2087 ret = rbd_cls_object_map_update(req, which, obj_req->ex.oe_objno, in rbd_object_map_update()
2124 static int rbd_obj_calc_img_extents(struct rbd_obj_request *obj_req, in rbd_obj_calc_img_extents() argument
2127 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_calc_img_extents()
2133 ret = ceph_extent_to_file(&rbd_dev->layout, obj_req->ex.oe_objno, in rbd_obj_calc_img_extents()
2134 entire ? 0 : obj_req->ex.oe_off, in rbd_obj_calc_img_extents()
2136 obj_req->ex.oe_len, in rbd_obj_calc_img_extents()
2137 &obj_req->img_extents, in rbd_obj_calc_img_extents()
2138 &obj_req->num_img_extents); in rbd_obj_calc_img_extents()
2142 prune_extents(obj_req->img_extents, &obj_req->num_img_extents, in rbd_obj_calc_img_extents()
2149 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_setup_data() local
2151 switch (obj_req->img_request->data_type) { in rbd_osd_setup_data()
2154 &obj_req->bio_pos, in rbd_osd_setup_data()
2155 obj_req->ex.oe_len); in rbd_osd_setup_data()
2159 rbd_assert(obj_req->bvec_pos.iter.bi_size == in rbd_osd_setup_data()
2160 obj_req->ex.oe_len); in rbd_osd_setup_data()
2161 rbd_assert(obj_req->bvec_idx == obj_req->bvec_count); in rbd_osd_setup_data()
2163 &obj_req->bvec_pos); in rbd_osd_setup_data()
2196 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_setup_copyup() local
2203 osd_req_op_cls_request_data_bvecs(osd_req, which, obj_req->copyup_bvecs, in rbd_osd_setup_copyup()
2204 obj_req->copyup_bvec_count, bytes); in rbd_osd_setup_copyup()
2208 static int rbd_obj_init_read(struct rbd_obj_request *obj_req) in rbd_obj_init_read() argument
2210 obj_req->read_state = RBD_OBJ_READ_START; in rbd_obj_init_read()
2217 struct rbd_obj_request *obj_req = osd_req->r_priv; in __rbd_osd_setup_write_ops() local
2218 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in __rbd_osd_setup_write_ops()
2222 !(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST)) { in __rbd_osd_setup_write_ops()
2229 if (rbd_obj_is_entire(obj_req)) in __rbd_osd_setup_write_ops()
2235 obj_req->ex.oe_off, obj_req->ex.oe_len, 0, 0); in __rbd_osd_setup_write_ops()
2239 static int rbd_obj_init_write(struct rbd_obj_request *obj_req) in rbd_obj_init_write() argument
2244 ret = rbd_obj_calc_img_extents(obj_req, true); in rbd_obj_init_write()
2248 if (rbd_obj_copyup_enabled(obj_req)) in rbd_obj_init_write()
2249 obj_req->flags |= RBD_OBJ_FLAG_COPYUP_ENABLED; in rbd_obj_init_write()
2251 obj_req->write_state = RBD_OBJ_WRITE_START; in rbd_obj_init_write()
2255 static u16 truncate_or_zero_opcode(struct rbd_obj_request *obj_req) in truncate_or_zero_opcode() argument
2257 return rbd_obj_is_tail(obj_req) ? CEPH_OSD_OP_TRUNCATE : in truncate_or_zero_opcode()
2264 struct rbd_obj_request *obj_req = osd_req->r_priv; in __rbd_osd_setup_discard_ops() local
2266 if (rbd_obj_is_entire(obj_req) && !obj_req->num_img_extents) { in __rbd_osd_setup_discard_ops()
2267 rbd_assert(obj_req->flags & RBD_OBJ_FLAG_DELETION); in __rbd_osd_setup_discard_ops()
2271 truncate_or_zero_opcode(obj_req), in __rbd_osd_setup_discard_ops()
2272 obj_req->ex.oe_off, obj_req->ex.oe_len, in __rbd_osd_setup_discard_ops()
2277 static int rbd_obj_init_discard(struct rbd_obj_request *obj_req) in rbd_obj_init_discard() argument
2279 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_init_discard()
2292 !rbd_obj_is_tail(obj_req)) { in rbd_obj_init_discard()
2293 off = round_up(obj_req->ex.oe_off, rbd_dev->opts->alloc_size); in rbd_obj_init_discard()
2294 next_off = round_down(obj_req->ex.oe_off + obj_req->ex.oe_len, in rbd_obj_init_discard()
2300 obj_req, obj_req->ex.oe_off, obj_req->ex.oe_len, in rbd_obj_init_discard()
2302 obj_req->ex.oe_off = off; in rbd_obj_init_discard()
2303 obj_req->ex.oe_len = next_off - off; in rbd_obj_init_discard()
2307 ret = rbd_obj_calc_img_extents(obj_req, true); in rbd_obj_init_discard()
2311 obj_req->flags |= RBD_OBJ_FLAG_NOOP_FOR_NONEXISTENT; in rbd_obj_init_discard()
2312 if (rbd_obj_is_entire(obj_req) && !obj_req->num_img_extents) in rbd_obj_init_discard()
2313 obj_req->flags |= RBD_OBJ_FLAG_DELETION; in rbd_obj_init_discard()
2315 obj_req->write_state = RBD_OBJ_WRITE_START; in rbd_obj_init_discard()
2322 struct rbd_obj_request *obj_req = osd_req->r_priv; in __rbd_osd_setup_zeroout_ops() local
2325 if (rbd_obj_is_entire(obj_req)) { in __rbd_osd_setup_zeroout_ops()
2326 if (obj_req->num_img_extents) { in __rbd_osd_setup_zeroout_ops()
2327 if (!(obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED)) in __rbd_osd_setup_zeroout_ops()
2332 rbd_assert(obj_req->flags & RBD_OBJ_FLAG_DELETION); in __rbd_osd_setup_zeroout_ops()
2338 opcode = truncate_or_zero_opcode(obj_req); in __rbd_osd_setup_zeroout_ops()
2343 obj_req->ex.oe_off, obj_req->ex.oe_len, in __rbd_osd_setup_zeroout_ops()
2347 static int rbd_obj_init_zeroout(struct rbd_obj_request *obj_req) in rbd_obj_init_zeroout() argument
2352 ret = rbd_obj_calc_img_extents(obj_req, true); in rbd_obj_init_zeroout()
2356 if (rbd_obj_copyup_enabled(obj_req)) in rbd_obj_init_zeroout()
2357 obj_req->flags |= RBD_OBJ_FLAG_COPYUP_ENABLED; in rbd_obj_init_zeroout()
2358 if (!obj_req->num_img_extents) { in rbd_obj_init_zeroout()
2359 obj_req->flags |= RBD_OBJ_FLAG_NOOP_FOR_NONEXISTENT; in rbd_obj_init_zeroout()
2360 if (rbd_obj_is_entire(obj_req)) in rbd_obj_init_zeroout()
2361 obj_req->flags |= RBD_OBJ_FLAG_DELETION; in rbd_obj_init_zeroout()
2364 obj_req->write_state = RBD_OBJ_WRITE_START; in rbd_obj_init_zeroout()
2368 static int count_write_ops(struct rbd_obj_request *obj_req) in count_write_ops() argument
2370 struct rbd_img_request *img_req = obj_req->img_request; in count_write_ops()
2375 !(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST)) in count_write_ops()
2382 if (rbd_obj_is_entire(obj_req) && obj_req->num_img_extents && in count_write_ops()
2383 !(obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED)) in count_write_ops()
2395 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_setup_write_ops() local
2397 switch (obj_req->img_request->op_type) { in rbd_osd_setup_write_ops()
2419 struct rbd_obj_request *obj_req, *next_obj_req; in __rbd_img_fill_request() local
2422 for_each_obj_request_safe(img_req, obj_req, next_obj_req) { in __rbd_img_fill_request()
2425 ret = rbd_obj_init_read(obj_req); in __rbd_img_fill_request()
2428 ret = rbd_obj_init_write(obj_req); in __rbd_img_fill_request()
2431 ret = rbd_obj_init_discard(obj_req); in __rbd_img_fill_request()
2434 ret = rbd_obj_init_zeroout(obj_req); in __rbd_img_fill_request()
2442 rbd_img_obj_request_del(img_req, obj_req); in __rbd_img_fill_request()
2468 struct rbd_obj_request *obj_req; in alloc_object_extent() local
2470 obj_req = rbd_obj_request_create(); in alloc_object_extent()
2471 if (!obj_req) in alloc_object_extent()
2474 rbd_img_obj_request_add(img_req, obj_req); in alloc_object_extent()
2475 return &obj_req->ex; in alloc_object_extent()
2538 struct rbd_obj_request *obj_req; in rbd_img_fill_request() local
2568 for_each_obj_request(img_req, obj_req) { in rbd_img_fill_request()
2569 obj_req->bvec_pos.bvecs = kmalloc_array(obj_req->bvec_count, in rbd_img_fill_request()
2570 sizeof(*obj_req->bvec_pos.bvecs), in rbd_img_fill_request()
2572 if (!obj_req->bvec_pos.bvecs) in rbd_img_fill_request()
2609 struct rbd_obj_request *obj_req = in set_bio_pos() local
2614 obj_req->bio_pos = *it; in set_bio_pos()
2620 struct rbd_obj_request *obj_req = in count_bio_bvecs() local
2626 obj_req->bvec_count++; in count_bio_bvecs()
2633 struct rbd_obj_request *obj_req = in copy_bio_bvecs() local
2639 obj_req->bvec_pos.bvecs[obj_req->bvec_idx++] = bv; in copy_bio_bvecs()
2640 obj_req->bvec_pos.iter.bi_size += bv.bv_len; in copy_bio_bvecs()
2672 struct rbd_obj_request *obj_req = in set_bvec_pos() local
2676 obj_req->bvec_pos = *it; in set_bvec_pos()
2677 ceph_bvec_iter_shorten(&obj_req->bvec_pos, bytes); in set_bvec_pos()
2683 struct rbd_obj_request *obj_req = in count_bvecs() local
2688 obj_req->bvec_count++; in count_bvecs()
2694 struct rbd_obj_request *obj_req = in copy_bvecs() local
2699 obj_req->bvec_pos.bvecs[obj_req->bvec_idx++] = bv; in copy_bvecs()
2700 obj_req->bvec_pos.iter.bi_size += bv.bv_len; in copy_bvecs()
2751 static bool rbd_obj_may_exist(struct rbd_obj_request *obj_req) in rbd_obj_may_exist() argument
2753 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_may_exist()
2755 if (rbd_object_map_may_exist(rbd_dev, obj_req->ex.oe_objno)) { in rbd_obj_may_exist()
2756 obj_req->flags |= RBD_OBJ_FLAG_MAY_EXIST; in rbd_obj_may_exist()
2760 dout("%s %p objno %llu assuming dne\n", __func__, obj_req, in rbd_obj_may_exist()
2761 obj_req->ex.oe_objno); in rbd_obj_may_exist()
2765 static int rbd_obj_read_object(struct rbd_obj_request *obj_req) in rbd_obj_read_object() argument
2770 osd_req = __rbd_obj_add_osd_request(obj_req, NULL, 1); in rbd_obj_read_object()
2775 obj_req->ex.oe_off, obj_req->ex.oe_len, 0, 0); in rbd_obj_read_object()
2787 static int rbd_obj_read_from_parent(struct rbd_obj_request *obj_req) in rbd_obj_read_from_parent() argument
2789 struct rbd_img_request *img_req = obj_req->img_request; in rbd_obj_read_from_parent()
2800 child_img_req->obj_request = obj_req; in rbd_obj_read_from_parent()
2807 obj_req); in rbd_obj_read_from_parent()
2813 obj_req->img_extents, in rbd_obj_read_from_parent()
2814 obj_req->num_img_extents, in rbd_obj_read_from_parent()
2815 &obj_req->bio_pos); in rbd_obj_read_from_parent()
2820 obj_req->img_extents, in rbd_obj_read_from_parent()
2821 obj_req->num_img_extents, in rbd_obj_read_from_parent()
2822 &obj_req->bvec_pos); in rbd_obj_read_from_parent()
2829 obj_req->img_extents, in rbd_obj_read_from_parent()
2830 obj_req->num_img_extents, in rbd_obj_read_from_parent()
2831 obj_req->copyup_bvecs); in rbd_obj_read_from_parent()
2843 static bool rbd_obj_advance_read(struct rbd_obj_request *obj_req, int *result) in rbd_obj_advance_read() argument
2845 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_advance_read()
2849 switch (obj_req->read_state) { in rbd_obj_advance_read()
2853 if (!rbd_obj_may_exist(obj_req)) { in rbd_obj_advance_read()
2855 obj_req->read_state = RBD_OBJ_READ_OBJECT; in rbd_obj_advance_read()
2859 ret = rbd_obj_read_object(obj_req); in rbd_obj_advance_read()
2864 obj_req->read_state = RBD_OBJ_READ_OBJECT; in rbd_obj_advance_read()
2869 ret = rbd_obj_calc_img_extents(obj_req, false); in rbd_obj_advance_read()
2874 if (obj_req->num_img_extents) { in rbd_obj_advance_read()
2875 ret = rbd_obj_read_from_parent(obj_req); in rbd_obj_advance_read()
2880 obj_req->read_state = RBD_OBJ_READ_PARENT; in rbd_obj_advance_read()
2891 rbd_obj_zero_range(obj_req, 0, obj_req->ex.oe_len); in rbd_obj_advance_read()
2894 if (*result < obj_req->ex.oe_len) in rbd_obj_advance_read()
2895 rbd_obj_zero_range(obj_req, *result, in rbd_obj_advance_read()
2896 obj_req->ex.oe_len - *result); in rbd_obj_advance_read()
2898 rbd_assert(*result == obj_req->ex.oe_len); in rbd_obj_advance_read()
2908 u32 obj_overlap = rbd_obj_img_extents_bytes(obj_req); in rbd_obj_advance_read()
2910 if (obj_overlap < obj_req->ex.oe_len) in rbd_obj_advance_read()
2911 rbd_obj_zero_range(obj_req, obj_overlap, in rbd_obj_advance_read()
2912 obj_req->ex.oe_len - obj_overlap); in rbd_obj_advance_read()
2920 static bool rbd_obj_write_is_noop(struct rbd_obj_request *obj_req) in rbd_obj_write_is_noop() argument
2922 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_write_is_noop()
2924 if (rbd_object_map_may_exist(rbd_dev, obj_req->ex.oe_objno)) in rbd_obj_write_is_noop()
2925 obj_req->flags |= RBD_OBJ_FLAG_MAY_EXIST; in rbd_obj_write_is_noop()
2927 if (!(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST) && in rbd_obj_write_is_noop()
2928 (obj_req->flags & RBD_OBJ_FLAG_NOOP_FOR_NONEXISTENT)) { in rbd_obj_write_is_noop()
2929 dout("%s %p noop for nonexistent\n", __func__, obj_req); in rbd_obj_write_is_noop()
2942 static int rbd_obj_write_pre_object_map(struct rbd_obj_request *obj_req) in rbd_obj_write_pre_object_map() argument
2944 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_write_pre_object_map()
2950 if (obj_req->flags & RBD_OBJ_FLAG_DELETION) in rbd_obj_write_pre_object_map()
2955 return rbd_object_map_update(obj_req, CEPH_NOSNAP, new_state, NULL); in rbd_obj_write_pre_object_map()
2958 static int rbd_obj_write_object(struct rbd_obj_request *obj_req) in rbd_obj_write_object() argument
2961 int num_ops = count_write_ops(obj_req); in rbd_obj_write_object()
2965 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED) in rbd_obj_write_object()
2968 osd_req = rbd_obj_add_osd_request(obj_req, num_ops); in rbd_obj_write_object()
2972 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED) { in rbd_obj_write_object()
3009 static int rbd_obj_copyup_empty_snapc(struct rbd_obj_request *obj_req, in rbd_obj_copyup_empty_snapc() argument
3015 dout("%s obj_req %p bytes %u\n", __func__, obj_req, bytes); in rbd_obj_copyup_empty_snapc()
3018 osd_req = __rbd_obj_add_osd_request(obj_req, &rbd_empty_snapc, 1); in rbd_obj_copyup_empty_snapc()
3036 static int rbd_obj_copyup_current_snapc(struct rbd_obj_request *obj_req, in rbd_obj_copyup_current_snapc() argument
3040 int num_ops = count_write_ops(obj_req); in rbd_obj_copyup_current_snapc()
3044 dout("%s obj_req %p bytes %u\n", __func__, obj_req, bytes); in rbd_obj_copyup_current_snapc()
3049 osd_req = rbd_obj_add_osd_request(obj_req, num_ops); in rbd_obj_copyup_current_snapc()
3070 static int setup_copyup_bvecs(struct rbd_obj_request *obj_req, u64 obj_overlap) in setup_copyup_bvecs() argument
3074 rbd_assert(!obj_req->copyup_bvecs); in setup_copyup_bvecs()
3075 obj_req->copyup_bvec_count = calc_pages_for(0, obj_overlap); in setup_copyup_bvecs()
3076 obj_req->copyup_bvecs = kcalloc(obj_req->copyup_bvec_count, in setup_copyup_bvecs()
3077 sizeof(*obj_req->copyup_bvecs), in setup_copyup_bvecs()
3079 if (!obj_req->copyup_bvecs) in setup_copyup_bvecs()
3082 for (i = 0; i < obj_req->copyup_bvec_count; i++) { in setup_copyup_bvecs()
3085 obj_req->copyup_bvecs[i].bv_page = alloc_page(GFP_NOIO); in setup_copyup_bvecs()
3086 if (!obj_req->copyup_bvecs[i].bv_page) in setup_copyup_bvecs()
3089 obj_req->copyup_bvecs[i].bv_offset = 0; in setup_copyup_bvecs()
3090 obj_req->copyup_bvecs[i].bv_len = len; in setup_copyup_bvecs()
3103 static int rbd_obj_copyup_read_parent(struct rbd_obj_request *obj_req) in rbd_obj_copyup_read_parent() argument
3105 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_copyup_read_parent()
3108 rbd_assert(obj_req->num_img_extents); in rbd_obj_copyup_read_parent()
3109 prune_extents(obj_req->img_extents, &obj_req->num_img_extents, in rbd_obj_copyup_read_parent()
3111 if (!obj_req->num_img_extents) { in rbd_obj_copyup_read_parent()
3118 return rbd_obj_copyup_current_snapc(obj_req, MODS_ONLY); in rbd_obj_copyup_read_parent()
3121 ret = setup_copyup_bvecs(obj_req, rbd_obj_img_extents_bytes(obj_req)); in rbd_obj_copyup_read_parent()
3125 return rbd_obj_read_from_parent(obj_req); in rbd_obj_copyup_read_parent()
3128 static void rbd_obj_copyup_object_maps(struct rbd_obj_request *obj_req) in rbd_obj_copyup_object_maps() argument
3130 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_copyup_object_maps()
3131 struct ceph_snap_context *snapc = obj_req->img_request->snapc; in rbd_obj_copyup_object_maps()
3136 rbd_assert(!obj_req->pending.result && !obj_req->pending.num_pending); in rbd_obj_copyup_object_maps()
3141 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ZEROS) in rbd_obj_copyup_object_maps()
3151 ret = rbd_object_map_update(obj_req, snapc->snaps[i], in rbd_obj_copyup_object_maps()
3154 obj_req->pending.result = ret; in rbd_obj_copyup_object_maps()
3159 obj_req->pending.num_pending++; in rbd_obj_copyup_object_maps()
3163 static void rbd_obj_copyup_write_object(struct rbd_obj_request *obj_req) in rbd_obj_copyup_write_object() argument
3165 u32 bytes = rbd_obj_img_extents_bytes(obj_req); in rbd_obj_copyup_write_object()
3168 rbd_assert(!obj_req->pending.result && !obj_req->pending.num_pending); in rbd_obj_copyup_write_object()
3175 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ZEROS) in rbd_obj_copyup_write_object()
3178 if (obj_req->img_request->snapc->num_snaps && bytes > 0) { in rbd_obj_copyup_write_object()
3185 ret = rbd_obj_copyup_empty_snapc(obj_req, bytes); in rbd_obj_copyup_write_object()
3187 obj_req->pending.result = ret; in rbd_obj_copyup_write_object()
3191 obj_req->pending.num_pending++; in rbd_obj_copyup_write_object()
3195 ret = rbd_obj_copyup_current_snapc(obj_req, bytes); in rbd_obj_copyup_write_object()
3197 obj_req->pending.result = ret; in rbd_obj_copyup_write_object()
3201 obj_req->pending.num_pending++; in rbd_obj_copyup_write_object()
3204 static bool rbd_obj_advance_copyup(struct rbd_obj_request *obj_req, int *result) in rbd_obj_advance_copyup() argument
3206 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_advance_copyup()
3210 switch (obj_req->copyup_state) { in rbd_obj_advance_copyup()
3214 ret = rbd_obj_copyup_read_parent(obj_req); in rbd_obj_advance_copyup()
3219 if (obj_req->num_img_extents) in rbd_obj_advance_copyup()
3220 obj_req->copyup_state = RBD_OBJ_COPYUP_READ_PARENT; in rbd_obj_advance_copyup()
3222 obj_req->copyup_state = RBD_OBJ_COPYUP_WRITE_OBJECT; in rbd_obj_advance_copyup()
3228 if (is_zero_bvecs(obj_req->copyup_bvecs, in rbd_obj_advance_copyup()
3229 rbd_obj_img_extents_bytes(obj_req))) { in rbd_obj_advance_copyup()
3230 dout("%s %p detected zeros\n", __func__, obj_req); in rbd_obj_advance_copyup()
3231 obj_req->flags |= RBD_OBJ_FLAG_COPYUP_ZEROS; in rbd_obj_advance_copyup()
3234 rbd_obj_copyup_object_maps(obj_req); in rbd_obj_advance_copyup()
3235 if (!obj_req->pending.num_pending) { in rbd_obj_advance_copyup()
3236 *result = obj_req->pending.result; in rbd_obj_advance_copyup()
3237 obj_req->copyup_state = RBD_OBJ_COPYUP_OBJECT_MAPS; in rbd_obj_advance_copyup()
3240 obj_req->copyup_state = __RBD_OBJ_COPYUP_OBJECT_MAPS; in rbd_obj_advance_copyup()
3243 if (!pending_result_dec(&obj_req->pending, result)) in rbd_obj_advance_copyup()
3253 rbd_obj_copyup_write_object(obj_req); in rbd_obj_advance_copyup()
3254 if (!obj_req->pending.num_pending) { in rbd_obj_advance_copyup()
3255 *result = obj_req->pending.result; in rbd_obj_advance_copyup()
3256 obj_req->copyup_state = RBD_OBJ_COPYUP_WRITE_OBJECT; in rbd_obj_advance_copyup()
3259 obj_req->copyup_state = __RBD_OBJ_COPYUP_WRITE_OBJECT; in rbd_obj_advance_copyup()
3262 if (!pending_result_dec(&obj_req->pending, result)) in rbd_obj_advance_copyup()
3278 static int rbd_obj_write_post_object_map(struct rbd_obj_request *obj_req) in rbd_obj_write_post_object_map() argument
3280 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_write_post_object_map()
3286 if (!(obj_req->flags & RBD_OBJ_FLAG_DELETION)) in rbd_obj_write_post_object_map()
3289 return rbd_object_map_update(obj_req, CEPH_NOSNAP, OBJECT_NONEXISTENT, in rbd_obj_write_post_object_map()
3293 static bool rbd_obj_advance_write(struct rbd_obj_request *obj_req, int *result) in rbd_obj_advance_write() argument
3295 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_advance_write()
3299 switch (obj_req->write_state) { in rbd_obj_advance_write()
3303 if (rbd_obj_write_is_noop(obj_req)) in rbd_obj_advance_write()
3306 ret = rbd_obj_write_pre_object_map(obj_req); in rbd_obj_advance_write()
3311 obj_req->write_state = RBD_OBJ_WRITE_PRE_OBJECT_MAP; in rbd_obj_advance_write()
3321 ret = rbd_obj_write_object(obj_req); in rbd_obj_advance_write()
3326 obj_req->write_state = RBD_OBJ_WRITE_OBJECT; in rbd_obj_advance_write()
3330 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED) { in rbd_obj_advance_write()
3332 obj_req->copyup_state = RBD_OBJ_COPYUP_START; in rbd_obj_advance_write()
3333 obj_req->write_state = __RBD_OBJ_WRITE_COPYUP; in rbd_obj_advance_write()
3340 if (obj_req->flags & RBD_OBJ_FLAG_DELETION) in rbd_obj_advance_write()
3346 obj_req->write_state = RBD_OBJ_WRITE_COPYUP; in rbd_obj_advance_write()
3349 if (!rbd_obj_advance_copyup(obj_req, result)) in rbd_obj_advance_write()
3357 ret = rbd_obj_write_post_object_map(obj_req); in rbd_obj_advance_write()
3362 obj_req->write_state = RBD_OBJ_WRITE_POST_OBJECT_MAP; in rbd_obj_advance_write()
3379 static bool __rbd_obj_handle_request(struct rbd_obj_request *obj_req, in __rbd_obj_handle_request() argument
3382 struct rbd_img_request *img_req = obj_req->img_request; in __rbd_obj_handle_request()
3386 mutex_lock(&obj_req->state_mutex); in __rbd_obj_handle_request()
3388 done = rbd_obj_advance_read(obj_req, result); in __rbd_obj_handle_request()
3390 done = rbd_obj_advance_write(obj_req, result); in __rbd_obj_handle_request()
3391 mutex_unlock(&obj_req->state_mutex); in __rbd_obj_handle_request()
3396 obj_op_name(img_req->op_type), obj_req->ex.oe_objno, in __rbd_obj_handle_request()
3397 obj_req->ex.oe_off, obj_req->ex.oe_len, *result); in __rbd_obj_handle_request()
3406 static void rbd_obj_handle_request(struct rbd_obj_request *obj_req, int result) in rbd_obj_handle_request() argument
3408 if (__rbd_obj_handle_request(obj_req, &result)) in rbd_obj_handle_request()
3409 rbd_img_handle_request(obj_req->img_request, result); in rbd_obj_handle_request()
3489 struct rbd_obj_request *obj_req; in rbd_img_object_requests() local
3493 for_each_obj_request(img_req, obj_req) { in rbd_img_object_requests()
3496 if (__rbd_obj_handle_request(obj_req, &result)) { in rbd_img_object_requests()
3591 struct rbd_obj_request *obj_req = img_req->obj_request; in rbd_img_handle_request() local
3594 if (__rbd_obj_handle_request(obj_req, &result)) { in rbd_img_handle_request()
3595 img_req = obj_req->img_request; in rbd_img_handle_request()