Lines Matching refs:obj_req

644 static void rbd_obj_handle_request(struct rbd_obj_request *obj_req, int result);
1247 static void rbd_obj_zero_range(struct rbd_obj_request *obj_req, u32 off, in rbd_obj_zero_range() argument
1250 dout("%s %p data buf %u~%u\n", __func__, obj_req, off, bytes); in rbd_obj_zero_range()
1252 switch (obj_req->img_request->data_type) { in rbd_obj_zero_range()
1254 zero_bios(&obj_req->bio_pos, off, bytes); in rbd_obj_zero_range()
1258 zero_bvecs(&obj_req->bvec_pos, off, bytes); in rbd_obj_zero_range()
1295 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_submit() local
1298 __func__, osd_req, obj_req, obj_req->ex.oe_objno, in rbd_osd_submit()
1299 obj_req->ex.oe_off, obj_req->ex.oe_len); in rbd_osd_submit()
1318 static bool rbd_obj_is_entire(struct rbd_obj_request *obj_req) in rbd_obj_is_entire() argument
1320 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_is_entire()
1322 return !obj_req->ex.oe_off && in rbd_obj_is_entire()
1323 obj_req->ex.oe_len == rbd_dev->layout.object_size; in rbd_obj_is_entire()
1326 static bool rbd_obj_is_tail(struct rbd_obj_request *obj_req) in rbd_obj_is_tail() argument
1328 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_is_tail()
1330 return obj_req->ex.oe_off + obj_req->ex.oe_len == in rbd_obj_is_tail()
1337 static bool rbd_obj_copyup_enabled(struct rbd_obj_request *obj_req) in rbd_obj_copyup_enabled() argument
1339 if (!obj_req->num_img_extents || in rbd_obj_copyup_enabled()
1340 (rbd_obj_is_entire(obj_req) && in rbd_obj_copyup_enabled()
1341 !obj_req->img_request->snapc->num_snaps)) in rbd_obj_copyup_enabled()
1347 static u64 rbd_obj_img_extents_bytes(struct rbd_obj_request *obj_req) in rbd_obj_img_extents_bytes() argument
1349 return ceph_file_extents_bytes(obj_req->img_extents, in rbd_obj_img_extents_bytes()
1350 obj_req->num_img_extents); in rbd_obj_img_extents_bytes()
1369 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_req_callback() local
1373 osd_req->r_result, obj_req); in rbd_osd_req_callback()
1380 if (osd_req->r_result > 0 && rbd_img_is_write(obj_req->img_request)) in rbd_osd_req_callback()
1385 rbd_obj_handle_request(obj_req, result); in rbd_osd_req_callback()
1408 __rbd_obj_add_osd_request(struct rbd_obj_request *obj_req, in __rbd_obj_add_osd_request() argument
1411 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in __rbd_obj_add_osd_request()
1422 list_add_tail(&req->r_private_item, &obj_req->osd_reqs); in __rbd_obj_add_osd_request()
1424 req->r_priv = obj_req; in __rbd_obj_add_osd_request()
1435 obj_req->ex.oe_objno); in __rbd_obj_add_osd_request()
1443 rbd_obj_add_osd_request(struct rbd_obj_request *obj_req, int num_ops) in rbd_obj_add_osd_request() argument
1445 return __rbd_obj_add_osd_request(obj_req, obj_req->img_request->snapc, in rbd_obj_add_osd_request()
1927 static int rbd_object_map_update_finish(struct rbd_obj_request *obj_req, in rbd_object_map_update_finish() argument
1930 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_object_map_update_finish()
1955 rbd_assert(objno == obj_req->ex.oe_objno); in rbd_object_map_update_finish()
1974 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_object_map_callback() local
1978 osd_req->r_result, obj_req); in rbd_object_map_callback()
1980 result = rbd_object_map_update_finish(obj_req, osd_req); in rbd_object_map_callback()
1981 rbd_obj_handle_request(obj_req, result); in rbd_object_map_callback()
2034 static int rbd_object_map_update(struct rbd_obj_request *obj_req, u64 snap_id, in rbd_object_map_update() argument
2037 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_object_map_update()
2045 if (!update_needed(rbd_dev, obj_req->ex.oe_objno, new_state)) in rbd_object_map_update()
2055 list_add_tail(&req->r_private_item, &obj_req->osd_reqs); in rbd_object_map_update()
2057 req->r_priv = obj_req; in rbd_object_map_update()
2075 ret = rbd_cls_object_map_update(req, which, obj_req->ex.oe_objno, in rbd_object_map_update()
2112 static int rbd_obj_calc_img_extents(struct rbd_obj_request *obj_req, in rbd_obj_calc_img_extents() argument
2115 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_calc_img_extents()
2121 ret = ceph_extent_to_file(&rbd_dev->layout, obj_req->ex.oe_objno, in rbd_obj_calc_img_extents()
2122 entire ? 0 : obj_req->ex.oe_off, in rbd_obj_calc_img_extents()
2124 obj_req->ex.oe_len, in rbd_obj_calc_img_extents()
2125 &obj_req->img_extents, in rbd_obj_calc_img_extents()
2126 &obj_req->num_img_extents); in rbd_obj_calc_img_extents()
2130 prune_extents(obj_req->img_extents, &obj_req->num_img_extents, in rbd_obj_calc_img_extents()
2137 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_setup_data() local
2139 switch (obj_req->img_request->data_type) { in rbd_osd_setup_data()
2142 &obj_req->bio_pos, in rbd_osd_setup_data()
2143 obj_req->ex.oe_len); in rbd_osd_setup_data()
2147 rbd_assert(obj_req->bvec_pos.iter.bi_size == in rbd_osd_setup_data()
2148 obj_req->ex.oe_len); in rbd_osd_setup_data()
2149 rbd_assert(obj_req->bvec_idx == obj_req->bvec_count); in rbd_osd_setup_data()
2151 &obj_req->bvec_pos); in rbd_osd_setup_data()
2184 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_setup_copyup() local
2191 osd_req_op_cls_request_data_bvecs(osd_req, which, obj_req->copyup_bvecs, in rbd_osd_setup_copyup()
2192 obj_req->copyup_bvec_count, bytes); in rbd_osd_setup_copyup()
2196 static int rbd_obj_init_read(struct rbd_obj_request *obj_req) in rbd_obj_init_read() argument
2198 obj_req->read_state = RBD_OBJ_READ_START; in rbd_obj_init_read()
2205 struct rbd_obj_request *obj_req = osd_req->r_priv; in __rbd_osd_setup_write_ops() local
2206 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in __rbd_osd_setup_write_ops()
2210 !(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST)) { in __rbd_osd_setup_write_ops()
2217 if (rbd_obj_is_entire(obj_req)) in __rbd_osd_setup_write_ops()
2223 obj_req->ex.oe_off, obj_req->ex.oe_len, 0, 0); in __rbd_osd_setup_write_ops()
2227 static int rbd_obj_init_write(struct rbd_obj_request *obj_req) in rbd_obj_init_write() argument
2232 ret = rbd_obj_calc_img_extents(obj_req, true); in rbd_obj_init_write()
2236 if (rbd_obj_copyup_enabled(obj_req)) in rbd_obj_init_write()
2237 obj_req->flags |= RBD_OBJ_FLAG_COPYUP_ENABLED; in rbd_obj_init_write()
2239 obj_req->write_state = RBD_OBJ_WRITE_START; in rbd_obj_init_write()
2243 static u16 truncate_or_zero_opcode(struct rbd_obj_request *obj_req) in truncate_or_zero_opcode() argument
2245 return rbd_obj_is_tail(obj_req) ? CEPH_OSD_OP_TRUNCATE : in truncate_or_zero_opcode()
2252 struct rbd_obj_request *obj_req = osd_req->r_priv; in __rbd_osd_setup_discard_ops() local
2254 if (rbd_obj_is_entire(obj_req) && !obj_req->num_img_extents) { in __rbd_osd_setup_discard_ops()
2255 rbd_assert(obj_req->flags & RBD_OBJ_FLAG_DELETION); in __rbd_osd_setup_discard_ops()
2259 truncate_or_zero_opcode(obj_req), in __rbd_osd_setup_discard_ops()
2260 obj_req->ex.oe_off, obj_req->ex.oe_len, in __rbd_osd_setup_discard_ops()
2265 static int rbd_obj_init_discard(struct rbd_obj_request *obj_req) in rbd_obj_init_discard() argument
2267 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_init_discard()
2280 !rbd_obj_is_tail(obj_req)) { in rbd_obj_init_discard()
2281 off = round_up(obj_req->ex.oe_off, rbd_dev->opts->alloc_size); in rbd_obj_init_discard()
2282 next_off = round_down(obj_req->ex.oe_off + obj_req->ex.oe_len, in rbd_obj_init_discard()
2288 obj_req, obj_req->ex.oe_off, obj_req->ex.oe_len, in rbd_obj_init_discard()
2290 obj_req->ex.oe_off = off; in rbd_obj_init_discard()
2291 obj_req->ex.oe_len = next_off - off; in rbd_obj_init_discard()
2295 ret = rbd_obj_calc_img_extents(obj_req, true); in rbd_obj_init_discard()
2299 obj_req->flags |= RBD_OBJ_FLAG_NOOP_FOR_NONEXISTENT; in rbd_obj_init_discard()
2300 if (rbd_obj_is_entire(obj_req) && !obj_req->num_img_extents) in rbd_obj_init_discard()
2301 obj_req->flags |= RBD_OBJ_FLAG_DELETION; in rbd_obj_init_discard()
2303 obj_req->write_state = RBD_OBJ_WRITE_START; in rbd_obj_init_discard()
2310 struct rbd_obj_request *obj_req = osd_req->r_priv; in __rbd_osd_setup_zeroout_ops() local
2313 if (rbd_obj_is_entire(obj_req)) { in __rbd_osd_setup_zeroout_ops()
2314 if (obj_req->num_img_extents) { in __rbd_osd_setup_zeroout_ops()
2315 if (!(obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED)) in __rbd_osd_setup_zeroout_ops()
2320 rbd_assert(obj_req->flags & RBD_OBJ_FLAG_DELETION); in __rbd_osd_setup_zeroout_ops()
2326 opcode = truncate_or_zero_opcode(obj_req); in __rbd_osd_setup_zeroout_ops()
2331 obj_req->ex.oe_off, obj_req->ex.oe_len, in __rbd_osd_setup_zeroout_ops()
2335 static int rbd_obj_init_zeroout(struct rbd_obj_request *obj_req) in rbd_obj_init_zeroout() argument
2340 ret = rbd_obj_calc_img_extents(obj_req, true); in rbd_obj_init_zeroout()
2344 if (rbd_obj_copyup_enabled(obj_req)) in rbd_obj_init_zeroout()
2345 obj_req->flags |= RBD_OBJ_FLAG_COPYUP_ENABLED; in rbd_obj_init_zeroout()
2346 if (!obj_req->num_img_extents) { in rbd_obj_init_zeroout()
2347 obj_req->flags |= RBD_OBJ_FLAG_NOOP_FOR_NONEXISTENT; in rbd_obj_init_zeroout()
2348 if (rbd_obj_is_entire(obj_req)) in rbd_obj_init_zeroout()
2349 obj_req->flags |= RBD_OBJ_FLAG_DELETION; in rbd_obj_init_zeroout()
2352 obj_req->write_state = RBD_OBJ_WRITE_START; in rbd_obj_init_zeroout()
2356 static int count_write_ops(struct rbd_obj_request *obj_req) in count_write_ops() argument
2358 struct rbd_img_request *img_req = obj_req->img_request; in count_write_ops()
2363 !(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST)) in count_write_ops()
2370 if (rbd_obj_is_entire(obj_req) && obj_req->num_img_extents && in count_write_ops()
2371 !(obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED)) in count_write_ops()
2383 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_setup_write_ops() local
2385 switch (obj_req->img_request->op_type) { in rbd_osd_setup_write_ops()
2407 struct rbd_obj_request *obj_req, *next_obj_req; in __rbd_img_fill_request() local
2410 for_each_obj_request_safe(img_req, obj_req, next_obj_req) { in __rbd_img_fill_request()
2413 ret = rbd_obj_init_read(obj_req); in __rbd_img_fill_request()
2416 ret = rbd_obj_init_write(obj_req); in __rbd_img_fill_request()
2419 ret = rbd_obj_init_discard(obj_req); in __rbd_img_fill_request()
2422 ret = rbd_obj_init_zeroout(obj_req); in __rbd_img_fill_request()
2430 rbd_img_obj_request_del(img_req, obj_req); in __rbd_img_fill_request()
2456 struct rbd_obj_request *obj_req; in alloc_object_extent() local
2458 obj_req = rbd_obj_request_create(); in alloc_object_extent()
2459 if (!obj_req) in alloc_object_extent()
2462 rbd_img_obj_request_add(img_req, obj_req); in alloc_object_extent()
2463 return &obj_req->ex; in alloc_object_extent()
2526 struct rbd_obj_request *obj_req; in rbd_img_fill_request() local
2556 for_each_obj_request(img_req, obj_req) { in rbd_img_fill_request()
2557 obj_req->bvec_pos.bvecs = kmalloc_array(obj_req->bvec_count, in rbd_img_fill_request()
2558 sizeof(*obj_req->bvec_pos.bvecs), in rbd_img_fill_request()
2560 if (!obj_req->bvec_pos.bvecs) in rbd_img_fill_request()
2597 struct rbd_obj_request *obj_req = in set_bio_pos() local
2602 obj_req->bio_pos = *it; in set_bio_pos()
2608 struct rbd_obj_request *obj_req = in count_bio_bvecs() local
2614 obj_req->bvec_count++; in count_bio_bvecs()
2621 struct rbd_obj_request *obj_req = in copy_bio_bvecs() local
2627 obj_req->bvec_pos.bvecs[obj_req->bvec_idx++] = bv; in copy_bio_bvecs()
2628 obj_req->bvec_pos.iter.bi_size += bv.bv_len; in copy_bio_bvecs()
2660 struct rbd_obj_request *obj_req = in set_bvec_pos() local
2664 obj_req->bvec_pos = *it; in set_bvec_pos()
2665 ceph_bvec_iter_shorten(&obj_req->bvec_pos, bytes); in set_bvec_pos()
2671 struct rbd_obj_request *obj_req = in count_bvecs() local
2676 obj_req->bvec_count++; in count_bvecs()
2682 struct rbd_obj_request *obj_req = in copy_bvecs() local
2687 obj_req->bvec_pos.bvecs[obj_req->bvec_idx++] = bv; in copy_bvecs()
2688 obj_req->bvec_pos.iter.bi_size += bv.bv_len; in copy_bvecs()
2739 static bool rbd_obj_may_exist(struct rbd_obj_request *obj_req) in rbd_obj_may_exist() argument
2741 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_may_exist()
2743 if (rbd_object_map_may_exist(rbd_dev, obj_req->ex.oe_objno)) { in rbd_obj_may_exist()
2744 obj_req->flags |= RBD_OBJ_FLAG_MAY_EXIST; in rbd_obj_may_exist()
2748 dout("%s %p objno %llu assuming dne\n", __func__, obj_req, in rbd_obj_may_exist()
2749 obj_req->ex.oe_objno); in rbd_obj_may_exist()
2753 static int rbd_obj_read_object(struct rbd_obj_request *obj_req) in rbd_obj_read_object() argument
2758 osd_req = __rbd_obj_add_osd_request(obj_req, NULL, 1); in rbd_obj_read_object()
2763 obj_req->ex.oe_off, obj_req->ex.oe_len, 0, 0); in rbd_obj_read_object()
2775 static int rbd_obj_read_from_parent(struct rbd_obj_request *obj_req) in rbd_obj_read_from_parent() argument
2777 struct rbd_img_request *img_req = obj_req->img_request; in rbd_obj_read_from_parent()
2788 child_img_req->obj_request = obj_req; in rbd_obj_read_from_parent()
2795 obj_req); in rbd_obj_read_from_parent()
2801 obj_req->img_extents, in rbd_obj_read_from_parent()
2802 obj_req->num_img_extents, in rbd_obj_read_from_parent()
2803 &obj_req->bio_pos); in rbd_obj_read_from_parent()
2808 obj_req->img_extents, in rbd_obj_read_from_parent()
2809 obj_req->num_img_extents, in rbd_obj_read_from_parent()
2810 &obj_req->bvec_pos); in rbd_obj_read_from_parent()
2817 obj_req->img_extents, in rbd_obj_read_from_parent()
2818 obj_req->num_img_extents, in rbd_obj_read_from_parent()
2819 obj_req->copyup_bvecs); in rbd_obj_read_from_parent()
2831 static bool rbd_obj_advance_read(struct rbd_obj_request *obj_req, int *result) in rbd_obj_advance_read() argument
2833 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_advance_read()
2837 switch (obj_req->read_state) { in rbd_obj_advance_read()
2841 if (!rbd_obj_may_exist(obj_req)) { in rbd_obj_advance_read()
2843 obj_req->read_state = RBD_OBJ_READ_OBJECT; in rbd_obj_advance_read()
2847 ret = rbd_obj_read_object(obj_req); in rbd_obj_advance_read()
2852 obj_req->read_state = RBD_OBJ_READ_OBJECT; in rbd_obj_advance_read()
2857 ret = rbd_obj_calc_img_extents(obj_req, false); in rbd_obj_advance_read()
2862 if (obj_req->num_img_extents) { in rbd_obj_advance_read()
2863 ret = rbd_obj_read_from_parent(obj_req); in rbd_obj_advance_read()
2868 obj_req->read_state = RBD_OBJ_READ_PARENT; in rbd_obj_advance_read()
2879 rbd_obj_zero_range(obj_req, 0, obj_req->ex.oe_len); in rbd_obj_advance_read()
2882 if (*result < obj_req->ex.oe_len) in rbd_obj_advance_read()
2883 rbd_obj_zero_range(obj_req, *result, in rbd_obj_advance_read()
2884 obj_req->ex.oe_len - *result); in rbd_obj_advance_read()
2886 rbd_assert(*result == obj_req->ex.oe_len); in rbd_obj_advance_read()
2896 u32 obj_overlap = rbd_obj_img_extents_bytes(obj_req); in rbd_obj_advance_read()
2898 if (obj_overlap < obj_req->ex.oe_len) in rbd_obj_advance_read()
2899 rbd_obj_zero_range(obj_req, obj_overlap, in rbd_obj_advance_read()
2900 obj_req->ex.oe_len - obj_overlap); in rbd_obj_advance_read()
2908 static bool rbd_obj_write_is_noop(struct rbd_obj_request *obj_req) in rbd_obj_write_is_noop() argument
2910 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_write_is_noop()
2912 if (rbd_object_map_may_exist(rbd_dev, obj_req->ex.oe_objno)) in rbd_obj_write_is_noop()
2913 obj_req->flags |= RBD_OBJ_FLAG_MAY_EXIST; in rbd_obj_write_is_noop()
2915 if (!(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST) && in rbd_obj_write_is_noop()
2916 (obj_req->flags & RBD_OBJ_FLAG_NOOP_FOR_NONEXISTENT)) { in rbd_obj_write_is_noop()
2917 dout("%s %p noop for nonexistent\n", __func__, obj_req); in rbd_obj_write_is_noop()
2930 static int rbd_obj_write_pre_object_map(struct rbd_obj_request *obj_req) in rbd_obj_write_pre_object_map() argument
2932 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_write_pre_object_map()
2938 if (obj_req->flags & RBD_OBJ_FLAG_DELETION) in rbd_obj_write_pre_object_map()
2943 return rbd_object_map_update(obj_req, CEPH_NOSNAP, new_state, NULL); in rbd_obj_write_pre_object_map()
2946 static int rbd_obj_write_object(struct rbd_obj_request *obj_req) in rbd_obj_write_object() argument
2949 int num_ops = count_write_ops(obj_req); in rbd_obj_write_object()
2953 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED) in rbd_obj_write_object()
2956 osd_req = rbd_obj_add_osd_request(obj_req, num_ops); in rbd_obj_write_object()
2960 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED) { in rbd_obj_write_object()
2996 static int rbd_obj_copyup_empty_snapc(struct rbd_obj_request *obj_req, in rbd_obj_copyup_empty_snapc() argument
3002 dout("%s obj_req %p bytes %u\n", __func__, obj_req, bytes); in rbd_obj_copyup_empty_snapc()
3005 osd_req = __rbd_obj_add_osd_request(obj_req, &rbd_empty_snapc, 1); in rbd_obj_copyup_empty_snapc()
3023 static int rbd_obj_copyup_current_snapc(struct rbd_obj_request *obj_req, in rbd_obj_copyup_current_snapc() argument
3027 int num_ops = count_write_ops(obj_req); in rbd_obj_copyup_current_snapc()
3031 dout("%s obj_req %p bytes %u\n", __func__, obj_req, bytes); in rbd_obj_copyup_current_snapc()
3036 osd_req = rbd_obj_add_osd_request(obj_req, num_ops); in rbd_obj_copyup_current_snapc()
3057 static int setup_copyup_bvecs(struct rbd_obj_request *obj_req, u64 obj_overlap) in setup_copyup_bvecs() argument
3061 rbd_assert(!obj_req->copyup_bvecs); in setup_copyup_bvecs()
3062 obj_req->copyup_bvec_count = calc_pages_for(0, obj_overlap); in setup_copyup_bvecs()
3063 obj_req->copyup_bvecs = kcalloc(obj_req->copyup_bvec_count, in setup_copyup_bvecs()
3064 sizeof(*obj_req->copyup_bvecs), in setup_copyup_bvecs()
3066 if (!obj_req->copyup_bvecs) in setup_copyup_bvecs()
3069 for (i = 0; i < obj_req->copyup_bvec_count; i++) { in setup_copyup_bvecs()
3072 obj_req->copyup_bvecs[i].bv_page = alloc_page(GFP_NOIO); in setup_copyup_bvecs()
3073 if (!obj_req->copyup_bvecs[i].bv_page) in setup_copyup_bvecs()
3076 obj_req->copyup_bvecs[i].bv_offset = 0; in setup_copyup_bvecs()
3077 obj_req->copyup_bvecs[i].bv_len = len; in setup_copyup_bvecs()
3090 static int rbd_obj_copyup_read_parent(struct rbd_obj_request *obj_req) in rbd_obj_copyup_read_parent() argument
3092 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_copyup_read_parent()
3095 rbd_assert(obj_req->num_img_extents); in rbd_obj_copyup_read_parent()
3096 prune_extents(obj_req->img_extents, &obj_req->num_img_extents, in rbd_obj_copyup_read_parent()
3098 if (!obj_req->num_img_extents) { in rbd_obj_copyup_read_parent()
3105 return rbd_obj_copyup_current_snapc(obj_req, MODS_ONLY); in rbd_obj_copyup_read_parent()
3108 ret = setup_copyup_bvecs(obj_req, rbd_obj_img_extents_bytes(obj_req)); in rbd_obj_copyup_read_parent()
3112 return rbd_obj_read_from_parent(obj_req); in rbd_obj_copyup_read_parent()
3115 static void rbd_obj_copyup_object_maps(struct rbd_obj_request *obj_req) in rbd_obj_copyup_object_maps() argument
3117 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_copyup_object_maps()
3118 struct ceph_snap_context *snapc = obj_req->img_request->snapc; in rbd_obj_copyup_object_maps()
3123 rbd_assert(!obj_req->pending.result && !obj_req->pending.num_pending); in rbd_obj_copyup_object_maps()
3128 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ZEROS) in rbd_obj_copyup_object_maps()
3138 ret = rbd_object_map_update(obj_req, snapc->snaps[i], in rbd_obj_copyup_object_maps()
3141 obj_req->pending.result = ret; in rbd_obj_copyup_object_maps()
3146 obj_req->pending.num_pending++; in rbd_obj_copyup_object_maps()
3150 static void rbd_obj_copyup_write_object(struct rbd_obj_request *obj_req) in rbd_obj_copyup_write_object() argument
3152 u32 bytes = rbd_obj_img_extents_bytes(obj_req); in rbd_obj_copyup_write_object()
3155 rbd_assert(!obj_req->pending.result && !obj_req->pending.num_pending); in rbd_obj_copyup_write_object()
3162 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ZEROS) in rbd_obj_copyup_write_object()
3165 if (obj_req->img_request->snapc->num_snaps && bytes > 0) { in rbd_obj_copyup_write_object()
3172 ret = rbd_obj_copyup_empty_snapc(obj_req, bytes); in rbd_obj_copyup_write_object()
3174 obj_req->pending.result = ret; in rbd_obj_copyup_write_object()
3178 obj_req->pending.num_pending++; in rbd_obj_copyup_write_object()
3182 ret = rbd_obj_copyup_current_snapc(obj_req, bytes); in rbd_obj_copyup_write_object()
3184 obj_req->pending.result = ret; in rbd_obj_copyup_write_object()
3188 obj_req->pending.num_pending++; in rbd_obj_copyup_write_object()
3191 static bool rbd_obj_advance_copyup(struct rbd_obj_request *obj_req, int *result) in rbd_obj_advance_copyup() argument
3193 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_advance_copyup()
3197 switch (obj_req->copyup_state) { in rbd_obj_advance_copyup()
3201 ret = rbd_obj_copyup_read_parent(obj_req); in rbd_obj_advance_copyup()
3206 if (obj_req->num_img_extents) in rbd_obj_advance_copyup()
3207 obj_req->copyup_state = RBD_OBJ_COPYUP_READ_PARENT; in rbd_obj_advance_copyup()
3209 obj_req->copyup_state = RBD_OBJ_COPYUP_WRITE_OBJECT; in rbd_obj_advance_copyup()
3215 if (is_zero_bvecs(obj_req->copyup_bvecs, in rbd_obj_advance_copyup()
3216 rbd_obj_img_extents_bytes(obj_req))) { in rbd_obj_advance_copyup()
3217 dout("%s %p detected zeros\n", __func__, obj_req); in rbd_obj_advance_copyup()
3218 obj_req->flags |= RBD_OBJ_FLAG_COPYUP_ZEROS; in rbd_obj_advance_copyup()
3221 rbd_obj_copyup_object_maps(obj_req); in rbd_obj_advance_copyup()
3222 if (!obj_req->pending.num_pending) { in rbd_obj_advance_copyup()
3223 *result = obj_req->pending.result; in rbd_obj_advance_copyup()
3224 obj_req->copyup_state = RBD_OBJ_COPYUP_OBJECT_MAPS; in rbd_obj_advance_copyup()
3227 obj_req->copyup_state = __RBD_OBJ_COPYUP_OBJECT_MAPS; in rbd_obj_advance_copyup()
3230 if (!pending_result_dec(&obj_req->pending, result)) in rbd_obj_advance_copyup()
3240 rbd_obj_copyup_write_object(obj_req); in rbd_obj_advance_copyup()
3241 if (!obj_req->pending.num_pending) { in rbd_obj_advance_copyup()
3242 *result = obj_req->pending.result; in rbd_obj_advance_copyup()
3243 obj_req->copyup_state = RBD_OBJ_COPYUP_WRITE_OBJECT; in rbd_obj_advance_copyup()
3246 obj_req->copyup_state = __RBD_OBJ_COPYUP_WRITE_OBJECT; in rbd_obj_advance_copyup()
3249 if (!pending_result_dec(&obj_req->pending, result)) in rbd_obj_advance_copyup()
3265 static int rbd_obj_write_post_object_map(struct rbd_obj_request *obj_req) in rbd_obj_write_post_object_map() argument
3267 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_write_post_object_map()
3273 if (!(obj_req->flags & RBD_OBJ_FLAG_DELETION)) in rbd_obj_write_post_object_map()
3276 return rbd_object_map_update(obj_req, CEPH_NOSNAP, OBJECT_NONEXISTENT, in rbd_obj_write_post_object_map()
3280 static bool rbd_obj_advance_write(struct rbd_obj_request *obj_req, int *result) in rbd_obj_advance_write() argument
3282 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_advance_write()
3286 switch (obj_req->write_state) { in rbd_obj_advance_write()
3290 if (rbd_obj_write_is_noop(obj_req)) in rbd_obj_advance_write()
3293 ret = rbd_obj_write_pre_object_map(obj_req); in rbd_obj_advance_write()
3298 obj_req->write_state = RBD_OBJ_WRITE_PRE_OBJECT_MAP; in rbd_obj_advance_write()
3308 ret = rbd_obj_write_object(obj_req); in rbd_obj_advance_write()
3313 obj_req->write_state = RBD_OBJ_WRITE_OBJECT; in rbd_obj_advance_write()
3317 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED) { in rbd_obj_advance_write()
3319 obj_req->copyup_state = RBD_OBJ_COPYUP_START; in rbd_obj_advance_write()
3320 obj_req->write_state = __RBD_OBJ_WRITE_COPYUP; in rbd_obj_advance_write()
3327 if (obj_req->flags & RBD_OBJ_FLAG_DELETION) in rbd_obj_advance_write()
3333 obj_req->write_state = RBD_OBJ_WRITE_COPYUP; in rbd_obj_advance_write()
3336 if (!rbd_obj_advance_copyup(obj_req, result)) in rbd_obj_advance_write()
3344 ret = rbd_obj_write_post_object_map(obj_req); in rbd_obj_advance_write()
3349 obj_req->write_state = RBD_OBJ_WRITE_POST_OBJECT_MAP; in rbd_obj_advance_write()
3366 static bool __rbd_obj_handle_request(struct rbd_obj_request *obj_req, in __rbd_obj_handle_request() argument
3369 struct rbd_img_request *img_req = obj_req->img_request; in __rbd_obj_handle_request()
3373 mutex_lock(&obj_req->state_mutex); in __rbd_obj_handle_request()
3375 done = rbd_obj_advance_read(obj_req, result); in __rbd_obj_handle_request()
3377 done = rbd_obj_advance_write(obj_req, result); in __rbd_obj_handle_request()
3378 mutex_unlock(&obj_req->state_mutex); in __rbd_obj_handle_request()
3383 obj_op_name(img_req->op_type), obj_req->ex.oe_objno, in __rbd_obj_handle_request()
3384 obj_req->ex.oe_off, obj_req->ex.oe_len, *result); in __rbd_obj_handle_request()
3393 static void rbd_obj_handle_request(struct rbd_obj_request *obj_req, int result) in rbd_obj_handle_request() argument
3395 if (__rbd_obj_handle_request(obj_req, &result)) in rbd_obj_handle_request()
3396 rbd_img_handle_request(obj_req->img_request, result); in rbd_obj_handle_request()
3476 struct rbd_obj_request *obj_req; in rbd_img_object_requests() local
3480 for_each_obj_request(img_req, obj_req) { in rbd_img_object_requests()
3483 if (__rbd_obj_handle_request(obj_req, &result)) { in rbd_img_object_requests()
3578 struct rbd_obj_request *obj_req = img_req->obj_request; in rbd_img_handle_request() local
3581 if (__rbd_obj_handle_request(obj_req, &result)) { in rbd_img_handle_request()
3582 img_req = obj_req->img_request; in rbd_img_handle_request()