Lines Matching refs:obj_req
643 static void rbd_obj_handle_request(struct rbd_obj_request *obj_req, int result);
1250 static void rbd_obj_zero_range(struct rbd_obj_request *obj_req, u32 off, in rbd_obj_zero_range() argument
1253 dout("%s %p data buf %u~%u\n", __func__, obj_req, off, bytes); in rbd_obj_zero_range()
1255 switch (obj_req->img_request->data_type) { in rbd_obj_zero_range()
1257 zero_bios(&obj_req->bio_pos, off, bytes); in rbd_obj_zero_range()
1261 zero_bvecs(&obj_req->bvec_pos, off, bytes); in rbd_obj_zero_range()
1298 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_submit() local
1301 __func__, osd_req, obj_req, obj_req->ex.oe_objno, in rbd_osd_submit()
1302 obj_req->ex.oe_off, obj_req->ex.oe_len); in rbd_osd_submit()
1321 static bool rbd_obj_is_entire(struct rbd_obj_request *obj_req) in rbd_obj_is_entire() argument
1323 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_is_entire()
1325 return !obj_req->ex.oe_off && in rbd_obj_is_entire()
1326 obj_req->ex.oe_len == rbd_dev->layout.object_size; in rbd_obj_is_entire()
1329 static bool rbd_obj_is_tail(struct rbd_obj_request *obj_req) in rbd_obj_is_tail() argument
1331 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_is_tail()
1333 return obj_req->ex.oe_off + obj_req->ex.oe_len == in rbd_obj_is_tail()
1340 static void rbd_obj_set_copyup_enabled(struct rbd_obj_request *obj_req) in rbd_obj_set_copyup_enabled() argument
1342 rbd_assert(obj_req->img_request->snapc); in rbd_obj_set_copyup_enabled()
1344 if (obj_req->img_request->op_type == OBJ_OP_DISCARD) { in rbd_obj_set_copyup_enabled()
1345 dout("%s %p objno %llu discard\n", __func__, obj_req, in rbd_obj_set_copyup_enabled()
1346 obj_req->ex.oe_objno); in rbd_obj_set_copyup_enabled()
1350 if (!obj_req->num_img_extents) { in rbd_obj_set_copyup_enabled()
1351 dout("%s %p objno %llu not overlapping\n", __func__, obj_req, in rbd_obj_set_copyup_enabled()
1352 obj_req->ex.oe_objno); in rbd_obj_set_copyup_enabled()
1356 if (rbd_obj_is_entire(obj_req) && in rbd_obj_set_copyup_enabled()
1357 !obj_req->img_request->snapc->num_snaps) { in rbd_obj_set_copyup_enabled()
1358 dout("%s %p objno %llu entire\n", __func__, obj_req, in rbd_obj_set_copyup_enabled()
1359 obj_req->ex.oe_objno); in rbd_obj_set_copyup_enabled()
1363 obj_req->flags |= RBD_OBJ_FLAG_COPYUP_ENABLED; in rbd_obj_set_copyup_enabled()
1366 static u64 rbd_obj_img_extents_bytes(struct rbd_obj_request *obj_req) in rbd_obj_img_extents_bytes() argument
1368 return ceph_file_extents_bytes(obj_req->img_extents, in rbd_obj_img_extents_bytes()
1369 obj_req->num_img_extents); in rbd_obj_img_extents_bytes()
1388 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_req_callback() local
1392 osd_req->r_result, obj_req); in rbd_osd_req_callback()
1399 if (osd_req->r_result > 0 && rbd_img_is_write(obj_req->img_request)) in rbd_osd_req_callback()
1404 rbd_obj_handle_request(obj_req, result); in rbd_osd_req_callback()
1427 __rbd_obj_add_osd_request(struct rbd_obj_request *obj_req, in __rbd_obj_add_osd_request() argument
1430 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in __rbd_obj_add_osd_request()
1441 list_add_tail(&req->r_private_item, &obj_req->osd_reqs); in __rbd_obj_add_osd_request()
1443 req->r_priv = obj_req; in __rbd_obj_add_osd_request()
1454 obj_req->ex.oe_objno); in __rbd_obj_add_osd_request()
1462 rbd_obj_add_osd_request(struct rbd_obj_request *obj_req, int num_ops) in rbd_obj_add_osd_request() argument
1464 rbd_assert(obj_req->img_request->snapc); in rbd_obj_add_osd_request()
1465 return __rbd_obj_add_osd_request(obj_req, obj_req->img_request->snapc, in rbd_obj_add_osd_request()
1950 static int rbd_object_map_update_finish(struct rbd_obj_request *obj_req, in rbd_object_map_update_finish() argument
1953 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_object_map_update_finish()
1978 rbd_assert(objno == obj_req->ex.oe_objno); in rbd_object_map_update_finish()
1997 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_object_map_callback() local
2001 osd_req->r_result, obj_req); in rbd_object_map_callback()
2003 result = rbd_object_map_update_finish(obj_req, osd_req); in rbd_object_map_callback()
2004 rbd_obj_handle_request(obj_req, result); in rbd_object_map_callback()
2057 static int rbd_object_map_update(struct rbd_obj_request *obj_req, u64 snap_id, in rbd_object_map_update() argument
2060 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_object_map_update()
2068 if (!update_needed(rbd_dev, obj_req->ex.oe_objno, new_state)) in rbd_object_map_update()
2078 list_add_tail(&req->r_private_item, &obj_req->osd_reqs); in rbd_object_map_update()
2080 req->r_priv = obj_req; in rbd_object_map_update()
2098 ret = rbd_cls_object_map_update(req, which, obj_req->ex.oe_objno, in rbd_object_map_update()
2135 static int rbd_obj_calc_img_extents(struct rbd_obj_request *obj_req, in rbd_obj_calc_img_extents() argument
2138 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_calc_img_extents()
2144 ret = ceph_extent_to_file(&rbd_dev->layout, obj_req->ex.oe_objno, in rbd_obj_calc_img_extents()
2145 entire ? 0 : obj_req->ex.oe_off, in rbd_obj_calc_img_extents()
2147 obj_req->ex.oe_len, in rbd_obj_calc_img_extents()
2148 &obj_req->img_extents, in rbd_obj_calc_img_extents()
2149 &obj_req->num_img_extents); in rbd_obj_calc_img_extents()
2153 prune_extents(obj_req->img_extents, &obj_req->num_img_extents, in rbd_obj_calc_img_extents()
2160 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_setup_data() local
2162 switch (obj_req->img_request->data_type) { in rbd_osd_setup_data()
2165 &obj_req->bio_pos, in rbd_osd_setup_data()
2166 obj_req->ex.oe_len); in rbd_osd_setup_data()
2170 rbd_assert(obj_req->bvec_pos.iter.bi_size == in rbd_osd_setup_data()
2171 obj_req->ex.oe_len); in rbd_osd_setup_data()
2172 rbd_assert(obj_req->bvec_idx == obj_req->bvec_count); in rbd_osd_setup_data()
2174 &obj_req->bvec_pos); in rbd_osd_setup_data()
2207 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_setup_copyup() local
2214 osd_req_op_cls_request_data_bvecs(osd_req, which, obj_req->copyup_bvecs, in rbd_osd_setup_copyup()
2215 obj_req->copyup_bvec_count, bytes); in rbd_osd_setup_copyup()
2219 static int rbd_obj_init_read(struct rbd_obj_request *obj_req) in rbd_obj_init_read() argument
2221 obj_req->read_state = RBD_OBJ_READ_START; in rbd_obj_init_read()
2228 struct rbd_obj_request *obj_req = osd_req->r_priv; in __rbd_osd_setup_write_ops() local
2229 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in __rbd_osd_setup_write_ops()
2233 !(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST)) { in __rbd_osd_setup_write_ops()
2240 if (rbd_obj_is_entire(obj_req)) in __rbd_osd_setup_write_ops()
2246 obj_req->ex.oe_off, obj_req->ex.oe_len, 0, 0); in __rbd_osd_setup_write_ops()
2250 static int rbd_obj_init_write(struct rbd_obj_request *obj_req) in rbd_obj_init_write() argument
2255 ret = rbd_obj_calc_img_extents(obj_req, true); in rbd_obj_init_write()
2259 obj_req->write_state = RBD_OBJ_WRITE_START; in rbd_obj_init_write()
2263 static u16 truncate_or_zero_opcode(struct rbd_obj_request *obj_req) in truncate_or_zero_opcode() argument
2265 return rbd_obj_is_tail(obj_req) ? CEPH_OSD_OP_TRUNCATE : in truncate_or_zero_opcode()
2272 struct rbd_obj_request *obj_req = osd_req->r_priv; in __rbd_osd_setup_discard_ops() local
2274 if (rbd_obj_is_entire(obj_req) && !obj_req->num_img_extents) { in __rbd_osd_setup_discard_ops()
2275 rbd_assert(obj_req->flags & RBD_OBJ_FLAG_DELETION); in __rbd_osd_setup_discard_ops()
2279 truncate_or_zero_opcode(obj_req), in __rbd_osd_setup_discard_ops()
2280 obj_req->ex.oe_off, obj_req->ex.oe_len, in __rbd_osd_setup_discard_ops()
2285 static int rbd_obj_init_discard(struct rbd_obj_request *obj_req) in rbd_obj_init_discard() argument
2287 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_init_discard()
2300 !rbd_obj_is_tail(obj_req)) { in rbd_obj_init_discard()
2301 off = round_up(obj_req->ex.oe_off, rbd_dev->opts->alloc_size); in rbd_obj_init_discard()
2302 next_off = round_down(obj_req->ex.oe_off + obj_req->ex.oe_len, in rbd_obj_init_discard()
2308 obj_req, obj_req->ex.oe_off, obj_req->ex.oe_len, in rbd_obj_init_discard()
2310 obj_req->ex.oe_off = off; in rbd_obj_init_discard()
2311 obj_req->ex.oe_len = next_off - off; in rbd_obj_init_discard()
2315 ret = rbd_obj_calc_img_extents(obj_req, true); in rbd_obj_init_discard()
2319 obj_req->flags |= RBD_OBJ_FLAG_NOOP_FOR_NONEXISTENT; in rbd_obj_init_discard()
2320 if (rbd_obj_is_entire(obj_req) && !obj_req->num_img_extents) in rbd_obj_init_discard()
2321 obj_req->flags |= RBD_OBJ_FLAG_DELETION; in rbd_obj_init_discard()
2323 obj_req->write_state = RBD_OBJ_WRITE_START; in rbd_obj_init_discard()
2330 struct rbd_obj_request *obj_req = osd_req->r_priv; in __rbd_osd_setup_zeroout_ops() local
2333 if (rbd_obj_is_entire(obj_req)) { in __rbd_osd_setup_zeroout_ops()
2334 if (obj_req->num_img_extents) { in __rbd_osd_setup_zeroout_ops()
2335 if (!(obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED)) in __rbd_osd_setup_zeroout_ops()
2340 rbd_assert(obj_req->flags & RBD_OBJ_FLAG_DELETION); in __rbd_osd_setup_zeroout_ops()
2346 opcode = truncate_or_zero_opcode(obj_req); in __rbd_osd_setup_zeroout_ops()
2351 obj_req->ex.oe_off, obj_req->ex.oe_len, in __rbd_osd_setup_zeroout_ops()
2355 static int rbd_obj_init_zeroout(struct rbd_obj_request *obj_req) in rbd_obj_init_zeroout() argument
2360 ret = rbd_obj_calc_img_extents(obj_req, true); in rbd_obj_init_zeroout()
2364 if (!obj_req->num_img_extents) { in rbd_obj_init_zeroout()
2365 obj_req->flags |= RBD_OBJ_FLAG_NOOP_FOR_NONEXISTENT; in rbd_obj_init_zeroout()
2366 if (rbd_obj_is_entire(obj_req)) in rbd_obj_init_zeroout()
2367 obj_req->flags |= RBD_OBJ_FLAG_DELETION; in rbd_obj_init_zeroout()
2370 obj_req->write_state = RBD_OBJ_WRITE_START; in rbd_obj_init_zeroout()
2374 static int count_write_ops(struct rbd_obj_request *obj_req) in count_write_ops() argument
2376 struct rbd_img_request *img_req = obj_req->img_request; in count_write_ops()
2381 !(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST)) in count_write_ops()
2388 if (rbd_obj_is_entire(obj_req) && obj_req->num_img_extents && in count_write_ops()
2389 !(obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED)) in count_write_ops()
2401 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_setup_write_ops() local
2403 switch (obj_req->img_request->op_type) { in rbd_osd_setup_write_ops()
2425 struct rbd_obj_request *obj_req, *next_obj_req; in __rbd_img_fill_request() local
2428 for_each_obj_request_safe(img_req, obj_req, next_obj_req) { in __rbd_img_fill_request()
2431 ret = rbd_obj_init_read(obj_req); in __rbd_img_fill_request()
2434 ret = rbd_obj_init_write(obj_req); in __rbd_img_fill_request()
2437 ret = rbd_obj_init_discard(obj_req); in __rbd_img_fill_request()
2440 ret = rbd_obj_init_zeroout(obj_req); in __rbd_img_fill_request()
2448 rbd_img_obj_request_del(img_req, obj_req); in __rbd_img_fill_request()
2474 struct rbd_obj_request *obj_req; in alloc_object_extent() local
2476 obj_req = rbd_obj_request_create(); in alloc_object_extent()
2477 if (!obj_req) in alloc_object_extent()
2480 rbd_img_obj_request_add(img_req, obj_req); in alloc_object_extent()
2481 return &obj_req->ex; in alloc_object_extent()
2544 struct rbd_obj_request *obj_req; in rbd_img_fill_request() local
2574 for_each_obj_request(img_req, obj_req) { in rbd_img_fill_request()
2575 obj_req->bvec_pos.bvecs = kmalloc_array(obj_req->bvec_count, in rbd_img_fill_request()
2576 sizeof(*obj_req->bvec_pos.bvecs), in rbd_img_fill_request()
2578 if (!obj_req->bvec_pos.bvecs) in rbd_img_fill_request()
2615 struct rbd_obj_request *obj_req = in set_bio_pos() local
2620 obj_req->bio_pos = *it; in set_bio_pos()
2626 struct rbd_obj_request *obj_req = in count_bio_bvecs() local
2632 obj_req->bvec_count++; in count_bio_bvecs()
2639 struct rbd_obj_request *obj_req = in copy_bio_bvecs() local
2645 obj_req->bvec_pos.bvecs[obj_req->bvec_idx++] = bv; in copy_bio_bvecs()
2646 obj_req->bvec_pos.iter.bi_size += bv.bv_len; in copy_bio_bvecs()
2678 struct rbd_obj_request *obj_req = in set_bvec_pos() local
2682 obj_req->bvec_pos = *it; in set_bvec_pos()
2683 ceph_bvec_iter_shorten(&obj_req->bvec_pos, bytes); in set_bvec_pos()
2689 struct rbd_obj_request *obj_req = in count_bvecs() local
2694 obj_req->bvec_count++; in count_bvecs()
2700 struct rbd_obj_request *obj_req = in copy_bvecs() local
2705 obj_req->bvec_pos.bvecs[obj_req->bvec_idx++] = bv; in copy_bvecs()
2706 obj_req->bvec_pos.iter.bi_size += bv.bv_len; in copy_bvecs()
2757 static bool rbd_obj_may_exist(struct rbd_obj_request *obj_req) in rbd_obj_may_exist() argument
2759 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_may_exist()
2761 if (rbd_object_map_may_exist(rbd_dev, obj_req->ex.oe_objno)) { in rbd_obj_may_exist()
2762 obj_req->flags |= RBD_OBJ_FLAG_MAY_EXIST; in rbd_obj_may_exist()
2766 dout("%s %p objno %llu assuming dne\n", __func__, obj_req, in rbd_obj_may_exist()
2767 obj_req->ex.oe_objno); in rbd_obj_may_exist()
2771 static int rbd_obj_read_object(struct rbd_obj_request *obj_req) in rbd_obj_read_object() argument
2776 osd_req = __rbd_obj_add_osd_request(obj_req, NULL, 1); in rbd_obj_read_object()
2781 obj_req->ex.oe_off, obj_req->ex.oe_len, 0, 0); in rbd_obj_read_object()
2793 static int rbd_obj_read_from_parent(struct rbd_obj_request *obj_req) in rbd_obj_read_from_parent() argument
2795 struct rbd_img_request *img_req = obj_req->img_request; in rbd_obj_read_from_parent()
2806 child_img_req->obj_request = obj_req; in rbd_obj_read_from_parent()
2813 obj_req); in rbd_obj_read_from_parent()
2819 obj_req->img_extents, in rbd_obj_read_from_parent()
2820 obj_req->num_img_extents, in rbd_obj_read_from_parent()
2821 &obj_req->bio_pos); in rbd_obj_read_from_parent()
2826 obj_req->img_extents, in rbd_obj_read_from_parent()
2827 obj_req->num_img_extents, in rbd_obj_read_from_parent()
2828 &obj_req->bvec_pos); in rbd_obj_read_from_parent()
2835 obj_req->img_extents, in rbd_obj_read_from_parent()
2836 obj_req->num_img_extents, in rbd_obj_read_from_parent()
2837 obj_req->copyup_bvecs); in rbd_obj_read_from_parent()
2849 static bool rbd_obj_advance_read(struct rbd_obj_request *obj_req, int *result) in rbd_obj_advance_read() argument
2851 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_advance_read()
2855 switch (obj_req->read_state) { in rbd_obj_advance_read()
2859 if (!rbd_obj_may_exist(obj_req)) { in rbd_obj_advance_read()
2861 obj_req->read_state = RBD_OBJ_READ_OBJECT; in rbd_obj_advance_read()
2865 ret = rbd_obj_read_object(obj_req); in rbd_obj_advance_read()
2870 obj_req->read_state = RBD_OBJ_READ_OBJECT; in rbd_obj_advance_read()
2875 ret = rbd_obj_calc_img_extents(obj_req, false); in rbd_obj_advance_read()
2880 if (obj_req->num_img_extents) { in rbd_obj_advance_read()
2881 ret = rbd_obj_read_from_parent(obj_req); in rbd_obj_advance_read()
2886 obj_req->read_state = RBD_OBJ_READ_PARENT; in rbd_obj_advance_read()
2897 rbd_obj_zero_range(obj_req, 0, obj_req->ex.oe_len); in rbd_obj_advance_read()
2900 if (*result < obj_req->ex.oe_len) in rbd_obj_advance_read()
2901 rbd_obj_zero_range(obj_req, *result, in rbd_obj_advance_read()
2902 obj_req->ex.oe_len - *result); in rbd_obj_advance_read()
2904 rbd_assert(*result == obj_req->ex.oe_len); in rbd_obj_advance_read()
2914 u32 obj_overlap = rbd_obj_img_extents_bytes(obj_req); in rbd_obj_advance_read()
2916 if (obj_overlap < obj_req->ex.oe_len) in rbd_obj_advance_read()
2917 rbd_obj_zero_range(obj_req, obj_overlap, in rbd_obj_advance_read()
2918 obj_req->ex.oe_len - obj_overlap); in rbd_obj_advance_read()
2926 static bool rbd_obj_write_is_noop(struct rbd_obj_request *obj_req) in rbd_obj_write_is_noop() argument
2928 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_write_is_noop()
2930 if (rbd_object_map_may_exist(rbd_dev, obj_req->ex.oe_objno)) in rbd_obj_write_is_noop()
2931 obj_req->flags |= RBD_OBJ_FLAG_MAY_EXIST; in rbd_obj_write_is_noop()
2933 if (!(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST) && in rbd_obj_write_is_noop()
2934 (obj_req->flags & RBD_OBJ_FLAG_NOOP_FOR_NONEXISTENT)) { in rbd_obj_write_is_noop()
2935 dout("%s %p noop for nonexistent\n", __func__, obj_req); in rbd_obj_write_is_noop()
2948 static int rbd_obj_write_pre_object_map(struct rbd_obj_request *obj_req) in rbd_obj_write_pre_object_map() argument
2950 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_write_pre_object_map()
2956 if (obj_req->flags & RBD_OBJ_FLAG_DELETION) in rbd_obj_write_pre_object_map()
2961 return rbd_object_map_update(obj_req, CEPH_NOSNAP, new_state, NULL); in rbd_obj_write_pre_object_map()
2964 static int rbd_obj_write_object(struct rbd_obj_request *obj_req) in rbd_obj_write_object() argument
2967 int num_ops = count_write_ops(obj_req); in rbd_obj_write_object()
2971 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED) in rbd_obj_write_object()
2974 osd_req = rbd_obj_add_osd_request(obj_req, num_ops); in rbd_obj_write_object()
2978 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED) { in rbd_obj_write_object()
3014 static int rbd_obj_copyup_empty_snapc(struct rbd_obj_request *obj_req, in rbd_obj_copyup_empty_snapc() argument
3020 dout("%s obj_req %p bytes %u\n", __func__, obj_req, bytes); in rbd_obj_copyup_empty_snapc()
3023 osd_req = __rbd_obj_add_osd_request(obj_req, &rbd_empty_snapc, 1); in rbd_obj_copyup_empty_snapc()
3041 static int rbd_obj_copyup_current_snapc(struct rbd_obj_request *obj_req, in rbd_obj_copyup_current_snapc() argument
3045 int num_ops = count_write_ops(obj_req); in rbd_obj_copyup_current_snapc()
3049 dout("%s obj_req %p bytes %u\n", __func__, obj_req, bytes); in rbd_obj_copyup_current_snapc()
3054 osd_req = rbd_obj_add_osd_request(obj_req, num_ops); in rbd_obj_copyup_current_snapc()
3075 static int setup_copyup_bvecs(struct rbd_obj_request *obj_req, u64 obj_overlap) in setup_copyup_bvecs() argument
3079 rbd_assert(!obj_req->copyup_bvecs); in setup_copyup_bvecs()
3080 obj_req->copyup_bvec_count = calc_pages_for(0, obj_overlap); in setup_copyup_bvecs()
3081 obj_req->copyup_bvecs = kcalloc(obj_req->copyup_bvec_count, in setup_copyup_bvecs()
3082 sizeof(*obj_req->copyup_bvecs), in setup_copyup_bvecs()
3084 if (!obj_req->copyup_bvecs) in setup_copyup_bvecs()
3087 for (i = 0; i < obj_req->copyup_bvec_count; i++) { in setup_copyup_bvecs()
3094 bvec_set_page(&obj_req->copyup_bvecs[i], page, len, 0); in setup_copyup_bvecs()
3107 static int rbd_obj_copyup_read_parent(struct rbd_obj_request *obj_req) in rbd_obj_copyup_read_parent() argument
3109 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_copyup_read_parent()
3112 rbd_assert(obj_req->num_img_extents); in rbd_obj_copyup_read_parent()
3113 prune_extents(obj_req->img_extents, &obj_req->num_img_extents, in rbd_obj_copyup_read_parent()
3115 if (!obj_req->num_img_extents) { in rbd_obj_copyup_read_parent()
3122 return rbd_obj_copyup_current_snapc(obj_req, MODS_ONLY); in rbd_obj_copyup_read_parent()
3125 ret = setup_copyup_bvecs(obj_req, rbd_obj_img_extents_bytes(obj_req)); in rbd_obj_copyup_read_parent()
3129 return rbd_obj_read_from_parent(obj_req); in rbd_obj_copyup_read_parent()
3132 static void rbd_obj_copyup_object_maps(struct rbd_obj_request *obj_req) in rbd_obj_copyup_object_maps() argument
3134 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_copyup_object_maps()
3135 struct ceph_snap_context *snapc = obj_req->img_request->snapc; in rbd_obj_copyup_object_maps()
3140 rbd_assert(!obj_req->pending.result && !obj_req->pending.num_pending); in rbd_obj_copyup_object_maps()
3145 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ZEROS) in rbd_obj_copyup_object_maps()
3155 ret = rbd_object_map_update(obj_req, snapc->snaps[i], in rbd_obj_copyup_object_maps()
3158 obj_req->pending.result = ret; in rbd_obj_copyup_object_maps()
3163 obj_req->pending.num_pending++; in rbd_obj_copyup_object_maps()
3167 static void rbd_obj_copyup_write_object(struct rbd_obj_request *obj_req) in rbd_obj_copyup_write_object() argument
3169 u32 bytes = rbd_obj_img_extents_bytes(obj_req); in rbd_obj_copyup_write_object()
3172 rbd_assert(!obj_req->pending.result && !obj_req->pending.num_pending); in rbd_obj_copyup_write_object()
3179 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ZEROS) in rbd_obj_copyup_write_object()
3182 if (obj_req->img_request->snapc->num_snaps && bytes > 0) { in rbd_obj_copyup_write_object()
3189 ret = rbd_obj_copyup_empty_snapc(obj_req, bytes); in rbd_obj_copyup_write_object()
3191 obj_req->pending.result = ret; in rbd_obj_copyup_write_object()
3195 obj_req->pending.num_pending++; in rbd_obj_copyup_write_object()
3199 ret = rbd_obj_copyup_current_snapc(obj_req, bytes); in rbd_obj_copyup_write_object()
3201 obj_req->pending.result = ret; in rbd_obj_copyup_write_object()
3205 obj_req->pending.num_pending++; in rbd_obj_copyup_write_object()
3208 static bool rbd_obj_advance_copyup(struct rbd_obj_request *obj_req, int *result) in rbd_obj_advance_copyup() argument
3210 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_advance_copyup()
3214 switch (obj_req->copyup_state) { in rbd_obj_advance_copyup()
3218 ret = rbd_obj_copyup_read_parent(obj_req); in rbd_obj_advance_copyup()
3223 if (obj_req->num_img_extents) in rbd_obj_advance_copyup()
3224 obj_req->copyup_state = RBD_OBJ_COPYUP_READ_PARENT; in rbd_obj_advance_copyup()
3226 obj_req->copyup_state = RBD_OBJ_COPYUP_WRITE_OBJECT; in rbd_obj_advance_copyup()
3232 if (is_zero_bvecs(obj_req->copyup_bvecs, in rbd_obj_advance_copyup()
3233 rbd_obj_img_extents_bytes(obj_req))) { in rbd_obj_advance_copyup()
3234 dout("%s %p detected zeros\n", __func__, obj_req); in rbd_obj_advance_copyup()
3235 obj_req->flags |= RBD_OBJ_FLAG_COPYUP_ZEROS; in rbd_obj_advance_copyup()
3238 rbd_obj_copyup_object_maps(obj_req); in rbd_obj_advance_copyup()
3239 if (!obj_req->pending.num_pending) { in rbd_obj_advance_copyup()
3240 *result = obj_req->pending.result; in rbd_obj_advance_copyup()
3241 obj_req->copyup_state = RBD_OBJ_COPYUP_OBJECT_MAPS; in rbd_obj_advance_copyup()
3244 obj_req->copyup_state = __RBD_OBJ_COPYUP_OBJECT_MAPS; in rbd_obj_advance_copyup()
3247 if (!pending_result_dec(&obj_req->pending, result)) in rbd_obj_advance_copyup()
3257 rbd_obj_copyup_write_object(obj_req); in rbd_obj_advance_copyup()
3258 if (!obj_req->pending.num_pending) { in rbd_obj_advance_copyup()
3259 *result = obj_req->pending.result; in rbd_obj_advance_copyup()
3260 obj_req->copyup_state = RBD_OBJ_COPYUP_WRITE_OBJECT; in rbd_obj_advance_copyup()
3263 obj_req->copyup_state = __RBD_OBJ_COPYUP_WRITE_OBJECT; in rbd_obj_advance_copyup()
3266 if (!pending_result_dec(&obj_req->pending, result)) in rbd_obj_advance_copyup()
3282 static int rbd_obj_write_post_object_map(struct rbd_obj_request *obj_req) in rbd_obj_write_post_object_map() argument
3284 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_write_post_object_map()
3290 if (!(obj_req->flags & RBD_OBJ_FLAG_DELETION)) in rbd_obj_write_post_object_map()
3293 return rbd_object_map_update(obj_req, CEPH_NOSNAP, OBJECT_NONEXISTENT, in rbd_obj_write_post_object_map()
3297 static bool rbd_obj_advance_write(struct rbd_obj_request *obj_req, int *result) in rbd_obj_advance_write() argument
3299 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_advance_write()
3303 switch (obj_req->write_state) { in rbd_obj_advance_write()
3307 rbd_obj_set_copyup_enabled(obj_req); in rbd_obj_advance_write()
3308 if (rbd_obj_write_is_noop(obj_req)) in rbd_obj_advance_write()
3311 ret = rbd_obj_write_pre_object_map(obj_req); in rbd_obj_advance_write()
3316 obj_req->write_state = RBD_OBJ_WRITE_PRE_OBJECT_MAP; in rbd_obj_advance_write()
3326 ret = rbd_obj_write_object(obj_req); in rbd_obj_advance_write()
3331 obj_req->write_state = RBD_OBJ_WRITE_OBJECT; in rbd_obj_advance_write()
3335 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED) { in rbd_obj_advance_write()
3337 obj_req->copyup_state = RBD_OBJ_COPYUP_START; in rbd_obj_advance_write()
3338 obj_req->write_state = __RBD_OBJ_WRITE_COPYUP; in rbd_obj_advance_write()
3345 if (obj_req->flags & RBD_OBJ_FLAG_DELETION) in rbd_obj_advance_write()
3351 obj_req->write_state = RBD_OBJ_WRITE_COPYUP; in rbd_obj_advance_write()
3354 if (!rbd_obj_advance_copyup(obj_req, result)) in rbd_obj_advance_write()
3362 ret = rbd_obj_write_post_object_map(obj_req); in rbd_obj_advance_write()
3367 obj_req->write_state = RBD_OBJ_WRITE_POST_OBJECT_MAP; in rbd_obj_advance_write()
3384 static bool __rbd_obj_handle_request(struct rbd_obj_request *obj_req, in __rbd_obj_handle_request() argument
3387 struct rbd_img_request *img_req = obj_req->img_request; in __rbd_obj_handle_request()
3391 mutex_lock(&obj_req->state_mutex); in __rbd_obj_handle_request()
3393 done = rbd_obj_advance_read(obj_req, result); in __rbd_obj_handle_request()
3395 done = rbd_obj_advance_write(obj_req, result); in __rbd_obj_handle_request()
3396 mutex_unlock(&obj_req->state_mutex); in __rbd_obj_handle_request()
3401 obj_op_name(img_req->op_type), obj_req->ex.oe_objno, in __rbd_obj_handle_request()
3402 obj_req->ex.oe_off, obj_req->ex.oe_len, *result); in __rbd_obj_handle_request()
3411 static void rbd_obj_handle_request(struct rbd_obj_request *obj_req, int result) in rbd_obj_handle_request() argument
3413 if (__rbd_obj_handle_request(obj_req, &result)) in rbd_obj_handle_request()
3414 rbd_img_handle_request(obj_req->img_request, result); in rbd_obj_handle_request()
3492 struct rbd_obj_request *obj_req; in rbd_img_object_requests() local
3505 for_each_obj_request(img_req, obj_req) { in rbd_img_object_requests()
3508 if (__rbd_obj_handle_request(obj_req, &result)) { in rbd_img_object_requests()
3599 struct rbd_obj_request *obj_req = img_req->obj_request; in rbd_img_handle_request() local
3602 if (__rbd_obj_handle_request(obj_req, &result)) { in rbd_img_handle_request()
3603 img_req = obj_req->img_request; in rbd_img_handle_request()