Lines Matching refs:obj_req
644 static void rbd_obj_handle_request(struct rbd_obj_request *obj_req, int result);
1248 static void rbd_obj_zero_range(struct rbd_obj_request *obj_req, u32 off, in rbd_obj_zero_range() argument
1251 dout("%s %p data buf %u~%u\n", __func__, obj_req, off, bytes); in rbd_obj_zero_range()
1253 switch (obj_req->img_request->data_type) { in rbd_obj_zero_range()
1255 zero_bios(&obj_req->bio_pos, off, bytes); in rbd_obj_zero_range()
1259 zero_bvecs(&obj_req->bvec_pos, off, bytes); in rbd_obj_zero_range()
1296 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_submit() local
1299 __func__, osd_req, obj_req, obj_req->ex.oe_objno, in rbd_osd_submit()
1300 obj_req->ex.oe_off, obj_req->ex.oe_len); in rbd_osd_submit()
1319 static bool rbd_obj_is_entire(struct rbd_obj_request *obj_req) in rbd_obj_is_entire() argument
1321 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_is_entire()
1323 return !obj_req->ex.oe_off && in rbd_obj_is_entire()
1324 obj_req->ex.oe_len == rbd_dev->layout.object_size; in rbd_obj_is_entire()
1327 static bool rbd_obj_is_tail(struct rbd_obj_request *obj_req) in rbd_obj_is_tail() argument
1329 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_is_tail()
1331 return obj_req->ex.oe_off + obj_req->ex.oe_len == in rbd_obj_is_tail()
1338 static bool rbd_obj_copyup_enabled(struct rbd_obj_request *obj_req) in rbd_obj_copyup_enabled() argument
1340 if (!obj_req->num_img_extents || in rbd_obj_copyup_enabled()
1341 (rbd_obj_is_entire(obj_req) && in rbd_obj_copyup_enabled()
1342 !obj_req->img_request->snapc->num_snaps)) in rbd_obj_copyup_enabled()
1348 static u64 rbd_obj_img_extents_bytes(struct rbd_obj_request *obj_req) in rbd_obj_img_extents_bytes() argument
1350 return ceph_file_extents_bytes(obj_req->img_extents, in rbd_obj_img_extents_bytes()
1351 obj_req->num_img_extents); in rbd_obj_img_extents_bytes()
1370 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_req_callback() local
1374 osd_req->r_result, obj_req); in rbd_osd_req_callback()
1381 if (osd_req->r_result > 0 && rbd_img_is_write(obj_req->img_request)) in rbd_osd_req_callback()
1386 rbd_obj_handle_request(obj_req, result); in rbd_osd_req_callback()
1409 __rbd_obj_add_osd_request(struct rbd_obj_request *obj_req, in __rbd_obj_add_osd_request() argument
1412 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in __rbd_obj_add_osd_request()
1423 list_add_tail(&req->r_private_item, &obj_req->osd_reqs); in __rbd_obj_add_osd_request()
1425 req->r_priv = obj_req; in __rbd_obj_add_osd_request()
1436 obj_req->ex.oe_objno); in __rbd_obj_add_osd_request()
1444 rbd_obj_add_osd_request(struct rbd_obj_request *obj_req, int num_ops) in rbd_obj_add_osd_request() argument
1446 return __rbd_obj_add_osd_request(obj_req, obj_req->img_request->snapc, in rbd_obj_add_osd_request()
1928 static int rbd_object_map_update_finish(struct rbd_obj_request *obj_req, in rbd_object_map_update_finish() argument
1931 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_object_map_update_finish()
1956 rbd_assert(objno == obj_req->ex.oe_objno); in rbd_object_map_update_finish()
1975 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_object_map_callback() local
1979 osd_req->r_result, obj_req); in rbd_object_map_callback()
1981 result = rbd_object_map_update_finish(obj_req, osd_req); in rbd_object_map_callback()
1982 rbd_obj_handle_request(obj_req, result); in rbd_object_map_callback()
2035 static int rbd_object_map_update(struct rbd_obj_request *obj_req, u64 snap_id, in rbd_object_map_update() argument
2038 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_object_map_update()
2046 if (!update_needed(rbd_dev, obj_req->ex.oe_objno, new_state)) in rbd_object_map_update()
2056 list_add_tail(&req->r_private_item, &obj_req->osd_reqs); in rbd_object_map_update()
2058 req->r_priv = obj_req; in rbd_object_map_update()
2076 ret = rbd_cls_object_map_update(req, which, obj_req->ex.oe_objno, in rbd_object_map_update()
2113 static int rbd_obj_calc_img_extents(struct rbd_obj_request *obj_req, in rbd_obj_calc_img_extents() argument
2116 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_calc_img_extents()
2122 ret = ceph_extent_to_file(&rbd_dev->layout, obj_req->ex.oe_objno, in rbd_obj_calc_img_extents()
2123 entire ? 0 : obj_req->ex.oe_off, in rbd_obj_calc_img_extents()
2125 obj_req->ex.oe_len, in rbd_obj_calc_img_extents()
2126 &obj_req->img_extents, in rbd_obj_calc_img_extents()
2127 &obj_req->num_img_extents); in rbd_obj_calc_img_extents()
2131 prune_extents(obj_req->img_extents, &obj_req->num_img_extents, in rbd_obj_calc_img_extents()
2138 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_setup_data() local
2140 switch (obj_req->img_request->data_type) { in rbd_osd_setup_data()
2143 &obj_req->bio_pos, in rbd_osd_setup_data()
2144 obj_req->ex.oe_len); in rbd_osd_setup_data()
2148 rbd_assert(obj_req->bvec_pos.iter.bi_size == in rbd_osd_setup_data()
2149 obj_req->ex.oe_len); in rbd_osd_setup_data()
2150 rbd_assert(obj_req->bvec_idx == obj_req->bvec_count); in rbd_osd_setup_data()
2152 &obj_req->bvec_pos); in rbd_osd_setup_data()
2185 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_setup_copyup() local
2192 osd_req_op_cls_request_data_bvecs(osd_req, which, obj_req->copyup_bvecs, in rbd_osd_setup_copyup()
2193 obj_req->copyup_bvec_count, bytes); in rbd_osd_setup_copyup()
2197 static int rbd_obj_init_read(struct rbd_obj_request *obj_req) in rbd_obj_init_read() argument
2199 obj_req->read_state = RBD_OBJ_READ_START; in rbd_obj_init_read()
2206 struct rbd_obj_request *obj_req = osd_req->r_priv; in __rbd_osd_setup_write_ops() local
2207 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in __rbd_osd_setup_write_ops()
2211 !(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST)) { in __rbd_osd_setup_write_ops()
2218 if (rbd_obj_is_entire(obj_req)) in __rbd_osd_setup_write_ops()
2224 obj_req->ex.oe_off, obj_req->ex.oe_len, 0, 0); in __rbd_osd_setup_write_ops()
2228 static int rbd_obj_init_write(struct rbd_obj_request *obj_req) in rbd_obj_init_write() argument
2233 ret = rbd_obj_calc_img_extents(obj_req, true); in rbd_obj_init_write()
2237 if (rbd_obj_copyup_enabled(obj_req)) in rbd_obj_init_write()
2238 obj_req->flags |= RBD_OBJ_FLAG_COPYUP_ENABLED; in rbd_obj_init_write()
2240 obj_req->write_state = RBD_OBJ_WRITE_START; in rbd_obj_init_write()
2244 static u16 truncate_or_zero_opcode(struct rbd_obj_request *obj_req) in truncate_or_zero_opcode() argument
2246 return rbd_obj_is_tail(obj_req) ? CEPH_OSD_OP_TRUNCATE : in truncate_or_zero_opcode()
2253 struct rbd_obj_request *obj_req = osd_req->r_priv; in __rbd_osd_setup_discard_ops() local
2255 if (rbd_obj_is_entire(obj_req) && !obj_req->num_img_extents) { in __rbd_osd_setup_discard_ops()
2256 rbd_assert(obj_req->flags & RBD_OBJ_FLAG_DELETION); in __rbd_osd_setup_discard_ops()
2260 truncate_or_zero_opcode(obj_req), in __rbd_osd_setup_discard_ops()
2261 obj_req->ex.oe_off, obj_req->ex.oe_len, in __rbd_osd_setup_discard_ops()
2266 static int rbd_obj_init_discard(struct rbd_obj_request *obj_req) in rbd_obj_init_discard() argument
2268 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_init_discard()
2281 !rbd_obj_is_tail(obj_req)) { in rbd_obj_init_discard()
2282 off = round_up(obj_req->ex.oe_off, rbd_dev->opts->alloc_size); in rbd_obj_init_discard()
2283 next_off = round_down(obj_req->ex.oe_off + obj_req->ex.oe_len, in rbd_obj_init_discard()
2289 obj_req, obj_req->ex.oe_off, obj_req->ex.oe_len, in rbd_obj_init_discard()
2291 obj_req->ex.oe_off = off; in rbd_obj_init_discard()
2292 obj_req->ex.oe_len = next_off - off; in rbd_obj_init_discard()
2296 ret = rbd_obj_calc_img_extents(obj_req, true); in rbd_obj_init_discard()
2300 obj_req->flags |= RBD_OBJ_FLAG_NOOP_FOR_NONEXISTENT; in rbd_obj_init_discard()
2301 if (rbd_obj_is_entire(obj_req) && !obj_req->num_img_extents) in rbd_obj_init_discard()
2302 obj_req->flags |= RBD_OBJ_FLAG_DELETION; in rbd_obj_init_discard()
2304 obj_req->write_state = RBD_OBJ_WRITE_START; in rbd_obj_init_discard()
2311 struct rbd_obj_request *obj_req = osd_req->r_priv; in __rbd_osd_setup_zeroout_ops() local
2314 if (rbd_obj_is_entire(obj_req)) { in __rbd_osd_setup_zeroout_ops()
2315 if (obj_req->num_img_extents) { in __rbd_osd_setup_zeroout_ops()
2316 if (!(obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED)) in __rbd_osd_setup_zeroout_ops()
2321 rbd_assert(obj_req->flags & RBD_OBJ_FLAG_DELETION); in __rbd_osd_setup_zeroout_ops()
2327 opcode = truncate_or_zero_opcode(obj_req); in __rbd_osd_setup_zeroout_ops()
2332 obj_req->ex.oe_off, obj_req->ex.oe_len, in __rbd_osd_setup_zeroout_ops()
2336 static int rbd_obj_init_zeroout(struct rbd_obj_request *obj_req) in rbd_obj_init_zeroout() argument
2341 ret = rbd_obj_calc_img_extents(obj_req, true); in rbd_obj_init_zeroout()
2345 if (rbd_obj_copyup_enabled(obj_req)) in rbd_obj_init_zeroout()
2346 obj_req->flags |= RBD_OBJ_FLAG_COPYUP_ENABLED; in rbd_obj_init_zeroout()
2347 if (!obj_req->num_img_extents) { in rbd_obj_init_zeroout()
2348 obj_req->flags |= RBD_OBJ_FLAG_NOOP_FOR_NONEXISTENT; in rbd_obj_init_zeroout()
2349 if (rbd_obj_is_entire(obj_req)) in rbd_obj_init_zeroout()
2350 obj_req->flags |= RBD_OBJ_FLAG_DELETION; in rbd_obj_init_zeroout()
2353 obj_req->write_state = RBD_OBJ_WRITE_START; in rbd_obj_init_zeroout()
2357 static int count_write_ops(struct rbd_obj_request *obj_req) in count_write_ops() argument
2359 struct rbd_img_request *img_req = obj_req->img_request; in count_write_ops()
2364 !(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST)) in count_write_ops()
2371 if (rbd_obj_is_entire(obj_req) && obj_req->num_img_extents && in count_write_ops()
2372 !(obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED)) in count_write_ops()
2384 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_setup_write_ops() local
2386 switch (obj_req->img_request->op_type) { in rbd_osd_setup_write_ops()
2408 struct rbd_obj_request *obj_req, *next_obj_req; in __rbd_img_fill_request() local
2411 for_each_obj_request_safe(img_req, obj_req, next_obj_req) { in __rbd_img_fill_request()
2414 ret = rbd_obj_init_read(obj_req); in __rbd_img_fill_request()
2417 ret = rbd_obj_init_write(obj_req); in __rbd_img_fill_request()
2420 ret = rbd_obj_init_discard(obj_req); in __rbd_img_fill_request()
2423 ret = rbd_obj_init_zeroout(obj_req); in __rbd_img_fill_request()
2431 rbd_img_obj_request_del(img_req, obj_req); in __rbd_img_fill_request()
2457 struct rbd_obj_request *obj_req; in alloc_object_extent() local
2459 obj_req = rbd_obj_request_create(); in alloc_object_extent()
2460 if (!obj_req) in alloc_object_extent()
2463 rbd_img_obj_request_add(img_req, obj_req); in alloc_object_extent()
2464 return &obj_req->ex; in alloc_object_extent()
2527 struct rbd_obj_request *obj_req; in rbd_img_fill_request() local
2557 for_each_obj_request(img_req, obj_req) { in rbd_img_fill_request()
2558 obj_req->bvec_pos.bvecs = kmalloc_array(obj_req->bvec_count, in rbd_img_fill_request()
2559 sizeof(*obj_req->bvec_pos.bvecs), in rbd_img_fill_request()
2561 if (!obj_req->bvec_pos.bvecs) in rbd_img_fill_request()
2598 struct rbd_obj_request *obj_req = in set_bio_pos() local
2603 obj_req->bio_pos = *it; in set_bio_pos()
2609 struct rbd_obj_request *obj_req = in count_bio_bvecs() local
2615 obj_req->bvec_count++; in count_bio_bvecs()
2622 struct rbd_obj_request *obj_req = in copy_bio_bvecs() local
2628 obj_req->bvec_pos.bvecs[obj_req->bvec_idx++] = bv; in copy_bio_bvecs()
2629 obj_req->bvec_pos.iter.bi_size += bv.bv_len; in copy_bio_bvecs()
2661 struct rbd_obj_request *obj_req = in set_bvec_pos() local
2665 obj_req->bvec_pos = *it; in set_bvec_pos()
2666 ceph_bvec_iter_shorten(&obj_req->bvec_pos, bytes); in set_bvec_pos()
2672 struct rbd_obj_request *obj_req = in count_bvecs() local
2677 obj_req->bvec_count++; in count_bvecs()
2683 struct rbd_obj_request *obj_req = in copy_bvecs() local
2688 obj_req->bvec_pos.bvecs[obj_req->bvec_idx++] = bv; in copy_bvecs()
2689 obj_req->bvec_pos.iter.bi_size += bv.bv_len; in copy_bvecs()
2740 static bool rbd_obj_may_exist(struct rbd_obj_request *obj_req) in rbd_obj_may_exist() argument
2742 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_may_exist()
2744 if (rbd_object_map_may_exist(rbd_dev, obj_req->ex.oe_objno)) { in rbd_obj_may_exist()
2745 obj_req->flags |= RBD_OBJ_FLAG_MAY_EXIST; in rbd_obj_may_exist()
2749 dout("%s %p objno %llu assuming dne\n", __func__, obj_req, in rbd_obj_may_exist()
2750 obj_req->ex.oe_objno); in rbd_obj_may_exist()
2754 static int rbd_obj_read_object(struct rbd_obj_request *obj_req) in rbd_obj_read_object() argument
2759 osd_req = __rbd_obj_add_osd_request(obj_req, NULL, 1); in rbd_obj_read_object()
2764 obj_req->ex.oe_off, obj_req->ex.oe_len, 0, 0); in rbd_obj_read_object()
2776 static int rbd_obj_read_from_parent(struct rbd_obj_request *obj_req) in rbd_obj_read_from_parent() argument
2778 struct rbd_img_request *img_req = obj_req->img_request; in rbd_obj_read_from_parent()
2789 child_img_req->obj_request = obj_req; in rbd_obj_read_from_parent()
2796 obj_req); in rbd_obj_read_from_parent()
2802 obj_req->img_extents, in rbd_obj_read_from_parent()
2803 obj_req->num_img_extents, in rbd_obj_read_from_parent()
2804 &obj_req->bio_pos); in rbd_obj_read_from_parent()
2809 obj_req->img_extents, in rbd_obj_read_from_parent()
2810 obj_req->num_img_extents, in rbd_obj_read_from_parent()
2811 &obj_req->bvec_pos); in rbd_obj_read_from_parent()
2818 obj_req->img_extents, in rbd_obj_read_from_parent()
2819 obj_req->num_img_extents, in rbd_obj_read_from_parent()
2820 obj_req->copyup_bvecs); in rbd_obj_read_from_parent()
2832 static bool rbd_obj_advance_read(struct rbd_obj_request *obj_req, int *result) in rbd_obj_advance_read() argument
2834 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_advance_read()
2838 switch (obj_req->read_state) { in rbd_obj_advance_read()
2842 if (!rbd_obj_may_exist(obj_req)) { in rbd_obj_advance_read()
2844 obj_req->read_state = RBD_OBJ_READ_OBJECT; in rbd_obj_advance_read()
2848 ret = rbd_obj_read_object(obj_req); in rbd_obj_advance_read()
2853 obj_req->read_state = RBD_OBJ_READ_OBJECT; in rbd_obj_advance_read()
2858 ret = rbd_obj_calc_img_extents(obj_req, false); in rbd_obj_advance_read()
2863 if (obj_req->num_img_extents) { in rbd_obj_advance_read()
2864 ret = rbd_obj_read_from_parent(obj_req); in rbd_obj_advance_read()
2869 obj_req->read_state = RBD_OBJ_READ_PARENT; in rbd_obj_advance_read()
2880 rbd_obj_zero_range(obj_req, 0, obj_req->ex.oe_len); in rbd_obj_advance_read()
2883 if (*result < obj_req->ex.oe_len) in rbd_obj_advance_read()
2884 rbd_obj_zero_range(obj_req, *result, in rbd_obj_advance_read()
2885 obj_req->ex.oe_len - *result); in rbd_obj_advance_read()
2887 rbd_assert(*result == obj_req->ex.oe_len); in rbd_obj_advance_read()
2897 u32 obj_overlap = rbd_obj_img_extents_bytes(obj_req); in rbd_obj_advance_read()
2899 if (obj_overlap < obj_req->ex.oe_len) in rbd_obj_advance_read()
2900 rbd_obj_zero_range(obj_req, obj_overlap, in rbd_obj_advance_read()
2901 obj_req->ex.oe_len - obj_overlap); in rbd_obj_advance_read()
2909 static bool rbd_obj_write_is_noop(struct rbd_obj_request *obj_req) in rbd_obj_write_is_noop() argument
2911 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_write_is_noop()
2913 if (rbd_object_map_may_exist(rbd_dev, obj_req->ex.oe_objno)) in rbd_obj_write_is_noop()
2914 obj_req->flags |= RBD_OBJ_FLAG_MAY_EXIST; in rbd_obj_write_is_noop()
2916 if (!(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST) && in rbd_obj_write_is_noop()
2917 (obj_req->flags & RBD_OBJ_FLAG_NOOP_FOR_NONEXISTENT)) { in rbd_obj_write_is_noop()
2918 dout("%s %p noop for nonexistent\n", __func__, obj_req); in rbd_obj_write_is_noop()
2931 static int rbd_obj_write_pre_object_map(struct rbd_obj_request *obj_req) in rbd_obj_write_pre_object_map() argument
2933 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_write_pre_object_map()
2939 if (obj_req->flags & RBD_OBJ_FLAG_DELETION) in rbd_obj_write_pre_object_map()
2944 return rbd_object_map_update(obj_req, CEPH_NOSNAP, new_state, NULL); in rbd_obj_write_pre_object_map()
2947 static int rbd_obj_write_object(struct rbd_obj_request *obj_req) in rbd_obj_write_object() argument
2950 int num_ops = count_write_ops(obj_req); in rbd_obj_write_object()
2954 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED) in rbd_obj_write_object()
2957 osd_req = rbd_obj_add_osd_request(obj_req, num_ops); in rbd_obj_write_object()
2961 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED) { in rbd_obj_write_object()
2997 static int rbd_obj_copyup_empty_snapc(struct rbd_obj_request *obj_req, in rbd_obj_copyup_empty_snapc() argument
3003 dout("%s obj_req %p bytes %u\n", __func__, obj_req, bytes); in rbd_obj_copyup_empty_snapc()
3006 osd_req = __rbd_obj_add_osd_request(obj_req, &rbd_empty_snapc, 1); in rbd_obj_copyup_empty_snapc()
3024 static int rbd_obj_copyup_current_snapc(struct rbd_obj_request *obj_req, in rbd_obj_copyup_current_snapc() argument
3028 int num_ops = count_write_ops(obj_req); in rbd_obj_copyup_current_snapc()
3032 dout("%s obj_req %p bytes %u\n", __func__, obj_req, bytes); in rbd_obj_copyup_current_snapc()
3037 osd_req = rbd_obj_add_osd_request(obj_req, num_ops); in rbd_obj_copyup_current_snapc()
3058 static int setup_copyup_bvecs(struct rbd_obj_request *obj_req, u64 obj_overlap) in setup_copyup_bvecs() argument
3062 rbd_assert(!obj_req->copyup_bvecs); in setup_copyup_bvecs()
3063 obj_req->copyup_bvec_count = calc_pages_for(0, obj_overlap); in setup_copyup_bvecs()
3064 obj_req->copyup_bvecs = kcalloc(obj_req->copyup_bvec_count, in setup_copyup_bvecs()
3065 sizeof(*obj_req->copyup_bvecs), in setup_copyup_bvecs()
3067 if (!obj_req->copyup_bvecs) in setup_copyup_bvecs()
3070 for (i = 0; i < obj_req->copyup_bvec_count; i++) { in setup_copyup_bvecs()
3073 obj_req->copyup_bvecs[i].bv_page = alloc_page(GFP_NOIO); in setup_copyup_bvecs()
3074 if (!obj_req->copyup_bvecs[i].bv_page) in setup_copyup_bvecs()
3077 obj_req->copyup_bvecs[i].bv_offset = 0; in setup_copyup_bvecs()
3078 obj_req->copyup_bvecs[i].bv_len = len; in setup_copyup_bvecs()
3091 static int rbd_obj_copyup_read_parent(struct rbd_obj_request *obj_req) in rbd_obj_copyup_read_parent() argument
3093 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_copyup_read_parent()
3096 rbd_assert(obj_req->num_img_extents); in rbd_obj_copyup_read_parent()
3097 prune_extents(obj_req->img_extents, &obj_req->num_img_extents, in rbd_obj_copyup_read_parent()
3099 if (!obj_req->num_img_extents) { in rbd_obj_copyup_read_parent()
3106 return rbd_obj_copyup_current_snapc(obj_req, MODS_ONLY); in rbd_obj_copyup_read_parent()
3109 ret = setup_copyup_bvecs(obj_req, rbd_obj_img_extents_bytes(obj_req)); in rbd_obj_copyup_read_parent()
3113 return rbd_obj_read_from_parent(obj_req); in rbd_obj_copyup_read_parent()
3116 static void rbd_obj_copyup_object_maps(struct rbd_obj_request *obj_req) in rbd_obj_copyup_object_maps() argument
3118 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_copyup_object_maps()
3119 struct ceph_snap_context *snapc = obj_req->img_request->snapc; in rbd_obj_copyup_object_maps()
3124 rbd_assert(!obj_req->pending.result && !obj_req->pending.num_pending); in rbd_obj_copyup_object_maps()
3129 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ZEROS) in rbd_obj_copyup_object_maps()
3139 ret = rbd_object_map_update(obj_req, snapc->snaps[i], in rbd_obj_copyup_object_maps()
3142 obj_req->pending.result = ret; in rbd_obj_copyup_object_maps()
3147 obj_req->pending.num_pending++; in rbd_obj_copyup_object_maps()
3151 static void rbd_obj_copyup_write_object(struct rbd_obj_request *obj_req) in rbd_obj_copyup_write_object() argument
3153 u32 bytes = rbd_obj_img_extents_bytes(obj_req); in rbd_obj_copyup_write_object()
3156 rbd_assert(!obj_req->pending.result && !obj_req->pending.num_pending); in rbd_obj_copyup_write_object()
3163 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ZEROS) in rbd_obj_copyup_write_object()
3166 if (obj_req->img_request->snapc->num_snaps && bytes > 0) { in rbd_obj_copyup_write_object()
3173 ret = rbd_obj_copyup_empty_snapc(obj_req, bytes); in rbd_obj_copyup_write_object()
3175 obj_req->pending.result = ret; in rbd_obj_copyup_write_object()
3179 obj_req->pending.num_pending++; in rbd_obj_copyup_write_object()
3183 ret = rbd_obj_copyup_current_snapc(obj_req, bytes); in rbd_obj_copyup_write_object()
3185 obj_req->pending.result = ret; in rbd_obj_copyup_write_object()
3189 obj_req->pending.num_pending++; in rbd_obj_copyup_write_object()
3192 static bool rbd_obj_advance_copyup(struct rbd_obj_request *obj_req, int *result) in rbd_obj_advance_copyup() argument
3194 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_advance_copyup()
3198 switch (obj_req->copyup_state) { in rbd_obj_advance_copyup()
3202 ret = rbd_obj_copyup_read_parent(obj_req); in rbd_obj_advance_copyup()
3207 if (obj_req->num_img_extents) in rbd_obj_advance_copyup()
3208 obj_req->copyup_state = RBD_OBJ_COPYUP_READ_PARENT; in rbd_obj_advance_copyup()
3210 obj_req->copyup_state = RBD_OBJ_COPYUP_WRITE_OBJECT; in rbd_obj_advance_copyup()
3216 if (is_zero_bvecs(obj_req->copyup_bvecs, in rbd_obj_advance_copyup()
3217 rbd_obj_img_extents_bytes(obj_req))) { in rbd_obj_advance_copyup()
3218 dout("%s %p detected zeros\n", __func__, obj_req); in rbd_obj_advance_copyup()
3219 obj_req->flags |= RBD_OBJ_FLAG_COPYUP_ZEROS; in rbd_obj_advance_copyup()
3222 rbd_obj_copyup_object_maps(obj_req); in rbd_obj_advance_copyup()
3223 if (!obj_req->pending.num_pending) { in rbd_obj_advance_copyup()
3224 *result = obj_req->pending.result; in rbd_obj_advance_copyup()
3225 obj_req->copyup_state = RBD_OBJ_COPYUP_OBJECT_MAPS; in rbd_obj_advance_copyup()
3228 obj_req->copyup_state = __RBD_OBJ_COPYUP_OBJECT_MAPS; in rbd_obj_advance_copyup()
3231 if (!pending_result_dec(&obj_req->pending, result)) in rbd_obj_advance_copyup()
3241 rbd_obj_copyup_write_object(obj_req); in rbd_obj_advance_copyup()
3242 if (!obj_req->pending.num_pending) { in rbd_obj_advance_copyup()
3243 *result = obj_req->pending.result; in rbd_obj_advance_copyup()
3244 obj_req->copyup_state = RBD_OBJ_COPYUP_WRITE_OBJECT; in rbd_obj_advance_copyup()
3247 obj_req->copyup_state = __RBD_OBJ_COPYUP_WRITE_OBJECT; in rbd_obj_advance_copyup()
3250 if (!pending_result_dec(&obj_req->pending, result)) in rbd_obj_advance_copyup()
3266 static int rbd_obj_write_post_object_map(struct rbd_obj_request *obj_req) in rbd_obj_write_post_object_map() argument
3268 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_write_post_object_map()
3274 if (!(obj_req->flags & RBD_OBJ_FLAG_DELETION)) in rbd_obj_write_post_object_map()
3277 return rbd_object_map_update(obj_req, CEPH_NOSNAP, OBJECT_NONEXISTENT, in rbd_obj_write_post_object_map()
3281 static bool rbd_obj_advance_write(struct rbd_obj_request *obj_req, int *result) in rbd_obj_advance_write() argument
3283 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_advance_write()
3287 switch (obj_req->write_state) { in rbd_obj_advance_write()
3291 if (rbd_obj_write_is_noop(obj_req)) in rbd_obj_advance_write()
3294 ret = rbd_obj_write_pre_object_map(obj_req); in rbd_obj_advance_write()
3299 obj_req->write_state = RBD_OBJ_WRITE_PRE_OBJECT_MAP; in rbd_obj_advance_write()
3309 ret = rbd_obj_write_object(obj_req); in rbd_obj_advance_write()
3314 obj_req->write_state = RBD_OBJ_WRITE_OBJECT; in rbd_obj_advance_write()
3318 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED) { in rbd_obj_advance_write()
3320 obj_req->copyup_state = RBD_OBJ_COPYUP_START; in rbd_obj_advance_write()
3321 obj_req->write_state = __RBD_OBJ_WRITE_COPYUP; in rbd_obj_advance_write()
3328 if (obj_req->flags & RBD_OBJ_FLAG_DELETION) in rbd_obj_advance_write()
3334 obj_req->write_state = RBD_OBJ_WRITE_COPYUP; in rbd_obj_advance_write()
3337 if (!rbd_obj_advance_copyup(obj_req, result)) in rbd_obj_advance_write()
3345 ret = rbd_obj_write_post_object_map(obj_req); in rbd_obj_advance_write()
3350 obj_req->write_state = RBD_OBJ_WRITE_POST_OBJECT_MAP; in rbd_obj_advance_write()
3367 static bool __rbd_obj_handle_request(struct rbd_obj_request *obj_req, in __rbd_obj_handle_request() argument
3370 struct rbd_img_request *img_req = obj_req->img_request; in __rbd_obj_handle_request()
3374 mutex_lock(&obj_req->state_mutex); in __rbd_obj_handle_request()
3376 done = rbd_obj_advance_read(obj_req, result); in __rbd_obj_handle_request()
3378 done = rbd_obj_advance_write(obj_req, result); in __rbd_obj_handle_request()
3379 mutex_unlock(&obj_req->state_mutex); in __rbd_obj_handle_request()
3384 obj_op_name(img_req->op_type), obj_req->ex.oe_objno, in __rbd_obj_handle_request()
3385 obj_req->ex.oe_off, obj_req->ex.oe_len, *result); in __rbd_obj_handle_request()
3394 static void rbd_obj_handle_request(struct rbd_obj_request *obj_req, int result) in rbd_obj_handle_request() argument
3396 if (__rbd_obj_handle_request(obj_req, &result)) in rbd_obj_handle_request()
3397 rbd_img_handle_request(obj_req->img_request, result); in rbd_obj_handle_request()
3477 struct rbd_obj_request *obj_req; in rbd_img_object_requests() local
3481 for_each_obj_request(img_req, obj_req) { in rbd_img_object_requests()
3484 if (__rbd_obj_handle_request(obj_req, &result)) { in rbd_img_object_requests()
3579 struct rbd_obj_request *obj_req = img_req->obj_request; in rbd_img_handle_request() local
3582 if (__rbd_obj_handle_request(obj_req, &result)) { in rbd_img_handle_request()
3583 img_req = obj_req->img_request; in rbd_img_handle_request()