• Home
  • Raw
  • Download

Lines Matching refs:obj_req

643 static void rbd_obj_handle_request(struct rbd_obj_request *obj_req, int result);
1313 static void rbd_obj_zero_range(struct rbd_obj_request *obj_req, u32 off, in rbd_obj_zero_range() argument
1316 dout("%s %p data buf %u~%u\n", __func__, obj_req, off, bytes); in rbd_obj_zero_range()
1318 switch (obj_req->img_request->data_type) { in rbd_obj_zero_range()
1320 zero_bios(&obj_req->bio_pos, off, bytes); in rbd_obj_zero_range()
1324 zero_bvecs(&obj_req->bvec_pos, off, bytes); in rbd_obj_zero_range()
1361 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_submit() local
1364 __func__, osd_req, obj_req, obj_req->ex.oe_objno, in rbd_osd_submit()
1365 obj_req->ex.oe_off, obj_req->ex.oe_len); in rbd_osd_submit()
1384 static bool rbd_obj_is_entire(struct rbd_obj_request *obj_req) in rbd_obj_is_entire() argument
1386 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_is_entire()
1388 return !obj_req->ex.oe_off && in rbd_obj_is_entire()
1389 obj_req->ex.oe_len == rbd_dev->layout.object_size; in rbd_obj_is_entire()
1392 static bool rbd_obj_is_tail(struct rbd_obj_request *obj_req) in rbd_obj_is_tail() argument
1394 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_is_tail()
1396 return obj_req->ex.oe_off + obj_req->ex.oe_len == in rbd_obj_is_tail()
1403 static void rbd_obj_set_copyup_enabled(struct rbd_obj_request *obj_req) in rbd_obj_set_copyup_enabled() argument
1405 rbd_assert(obj_req->img_request->snapc); in rbd_obj_set_copyup_enabled()
1407 if (obj_req->img_request->op_type == OBJ_OP_DISCARD) { in rbd_obj_set_copyup_enabled()
1408 dout("%s %p objno %llu discard\n", __func__, obj_req, in rbd_obj_set_copyup_enabled()
1409 obj_req->ex.oe_objno); in rbd_obj_set_copyup_enabled()
1413 if (!obj_req->num_img_extents) { in rbd_obj_set_copyup_enabled()
1414 dout("%s %p objno %llu not overlapping\n", __func__, obj_req, in rbd_obj_set_copyup_enabled()
1415 obj_req->ex.oe_objno); in rbd_obj_set_copyup_enabled()
1419 if (rbd_obj_is_entire(obj_req) && in rbd_obj_set_copyup_enabled()
1420 !obj_req->img_request->snapc->num_snaps) { in rbd_obj_set_copyup_enabled()
1421 dout("%s %p objno %llu entire\n", __func__, obj_req, in rbd_obj_set_copyup_enabled()
1422 obj_req->ex.oe_objno); in rbd_obj_set_copyup_enabled()
1426 obj_req->flags |= RBD_OBJ_FLAG_COPYUP_ENABLED; in rbd_obj_set_copyup_enabled()
1429 static u64 rbd_obj_img_extents_bytes(struct rbd_obj_request *obj_req) in rbd_obj_img_extents_bytes() argument
1431 return ceph_file_extents_bytes(obj_req->img_extents, in rbd_obj_img_extents_bytes()
1432 obj_req->num_img_extents); in rbd_obj_img_extents_bytes()
1451 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_req_callback() local
1455 osd_req->r_result, obj_req); in rbd_osd_req_callback()
1462 if (osd_req->r_result > 0 && rbd_img_is_write(obj_req->img_request)) in rbd_osd_req_callback()
1467 rbd_obj_handle_request(obj_req, result); in rbd_osd_req_callback()
1490 __rbd_obj_add_osd_request(struct rbd_obj_request *obj_req, in __rbd_obj_add_osd_request() argument
1493 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in __rbd_obj_add_osd_request()
1504 list_add_tail(&req->r_private_item, &obj_req->osd_reqs); in __rbd_obj_add_osd_request()
1506 req->r_priv = obj_req; in __rbd_obj_add_osd_request()
1517 obj_req->ex.oe_objno); in __rbd_obj_add_osd_request()
1525 rbd_obj_add_osd_request(struct rbd_obj_request *obj_req, int num_ops) in rbd_obj_add_osd_request() argument
1527 rbd_assert(obj_req->img_request->snapc); in rbd_obj_add_osd_request()
1528 return __rbd_obj_add_osd_request(obj_req, obj_req->img_request->snapc, in rbd_obj_add_osd_request()
2013 static int rbd_object_map_update_finish(struct rbd_obj_request *obj_req, in rbd_object_map_update_finish() argument
2016 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_object_map_update_finish()
2041 rbd_assert(objno == obj_req->ex.oe_objno); in rbd_object_map_update_finish()
2060 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_object_map_callback() local
2064 osd_req->r_result, obj_req); in rbd_object_map_callback()
2066 result = rbd_object_map_update_finish(obj_req, osd_req); in rbd_object_map_callback()
2067 rbd_obj_handle_request(obj_req, result); in rbd_object_map_callback()
2120 static int rbd_object_map_update(struct rbd_obj_request *obj_req, u64 snap_id, in rbd_object_map_update() argument
2123 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_object_map_update()
2131 if (!update_needed(rbd_dev, obj_req->ex.oe_objno, new_state)) in rbd_object_map_update()
2141 list_add_tail(&req->r_private_item, &obj_req->osd_reqs); in rbd_object_map_update()
2143 req->r_priv = obj_req; in rbd_object_map_update()
2161 ret = rbd_cls_object_map_update(req, which, obj_req->ex.oe_objno, in rbd_object_map_update()
2198 static int rbd_obj_calc_img_extents(struct rbd_obj_request *obj_req, in rbd_obj_calc_img_extents() argument
2201 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_calc_img_extents()
2207 ret = ceph_extent_to_file(&rbd_dev->layout, obj_req->ex.oe_objno, in rbd_obj_calc_img_extents()
2208 entire ? 0 : obj_req->ex.oe_off, in rbd_obj_calc_img_extents()
2210 obj_req->ex.oe_len, in rbd_obj_calc_img_extents()
2211 &obj_req->img_extents, in rbd_obj_calc_img_extents()
2212 &obj_req->num_img_extents); in rbd_obj_calc_img_extents()
2216 prune_extents(obj_req->img_extents, &obj_req->num_img_extents, in rbd_obj_calc_img_extents()
2223 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_setup_data() local
2225 switch (obj_req->img_request->data_type) { in rbd_osd_setup_data()
2228 &obj_req->bio_pos, in rbd_osd_setup_data()
2229 obj_req->ex.oe_len); in rbd_osd_setup_data()
2233 rbd_assert(obj_req->bvec_pos.iter.bi_size == in rbd_osd_setup_data()
2234 obj_req->ex.oe_len); in rbd_osd_setup_data()
2235 rbd_assert(obj_req->bvec_idx == obj_req->bvec_count); in rbd_osd_setup_data()
2237 &obj_req->bvec_pos); in rbd_osd_setup_data()
2270 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_setup_copyup() local
2277 osd_req_op_cls_request_data_bvecs(osd_req, which, obj_req->copyup_bvecs, in rbd_osd_setup_copyup()
2278 obj_req->copyup_bvec_count, bytes); in rbd_osd_setup_copyup()
2282 static int rbd_obj_init_read(struct rbd_obj_request *obj_req) in rbd_obj_init_read() argument
2284 obj_req->read_state = RBD_OBJ_READ_START; in rbd_obj_init_read()
2291 struct rbd_obj_request *obj_req = osd_req->r_priv; in __rbd_osd_setup_write_ops() local
2292 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in __rbd_osd_setup_write_ops()
2296 !(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST)) { in __rbd_osd_setup_write_ops()
2303 if (rbd_obj_is_entire(obj_req)) in __rbd_osd_setup_write_ops()
2309 obj_req->ex.oe_off, obj_req->ex.oe_len, 0, 0); in __rbd_osd_setup_write_ops()
2313 static int rbd_obj_init_write(struct rbd_obj_request *obj_req) in rbd_obj_init_write() argument
2318 ret = rbd_obj_calc_img_extents(obj_req, true); in rbd_obj_init_write()
2322 obj_req->write_state = RBD_OBJ_WRITE_START; in rbd_obj_init_write()
2326 static u16 truncate_or_zero_opcode(struct rbd_obj_request *obj_req) in truncate_or_zero_opcode() argument
2328 return rbd_obj_is_tail(obj_req) ? CEPH_OSD_OP_TRUNCATE : in truncate_or_zero_opcode()
2335 struct rbd_obj_request *obj_req = osd_req->r_priv; in __rbd_osd_setup_discard_ops() local
2337 if (rbd_obj_is_entire(obj_req) && !obj_req->num_img_extents) { in __rbd_osd_setup_discard_ops()
2338 rbd_assert(obj_req->flags & RBD_OBJ_FLAG_DELETION); in __rbd_osd_setup_discard_ops()
2342 truncate_or_zero_opcode(obj_req), in __rbd_osd_setup_discard_ops()
2343 obj_req->ex.oe_off, obj_req->ex.oe_len, in __rbd_osd_setup_discard_ops()
2348 static int rbd_obj_init_discard(struct rbd_obj_request *obj_req) in rbd_obj_init_discard() argument
2350 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_init_discard()
2363 !rbd_obj_is_tail(obj_req)) { in rbd_obj_init_discard()
2364 off = round_up(obj_req->ex.oe_off, rbd_dev->opts->alloc_size); in rbd_obj_init_discard()
2365 next_off = round_down(obj_req->ex.oe_off + obj_req->ex.oe_len, in rbd_obj_init_discard()
2371 obj_req, obj_req->ex.oe_off, obj_req->ex.oe_len, in rbd_obj_init_discard()
2373 obj_req->ex.oe_off = off; in rbd_obj_init_discard()
2374 obj_req->ex.oe_len = next_off - off; in rbd_obj_init_discard()
2378 ret = rbd_obj_calc_img_extents(obj_req, true); in rbd_obj_init_discard()
2382 obj_req->flags |= RBD_OBJ_FLAG_NOOP_FOR_NONEXISTENT; in rbd_obj_init_discard()
2383 if (rbd_obj_is_entire(obj_req) && !obj_req->num_img_extents) in rbd_obj_init_discard()
2384 obj_req->flags |= RBD_OBJ_FLAG_DELETION; in rbd_obj_init_discard()
2386 obj_req->write_state = RBD_OBJ_WRITE_START; in rbd_obj_init_discard()
2393 struct rbd_obj_request *obj_req = osd_req->r_priv; in __rbd_osd_setup_zeroout_ops() local
2396 if (rbd_obj_is_entire(obj_req)) { in __rbd_osd_setup_zeroout_ops()
2397 if (obj_req->num_img_extents) { in __rbd_osd_setup_zeroout_ops()
2398 if (!(obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED)) in __rbd_osd_setup_zeroout_ops()
2403 rbd_assert(obj_req->flags & RBD_OBJ_FLAG_DELETION); in __rbd_osd_setup_zeroout_ops()
2409 opcode = truncate_or_zero_opcode(obj_req); in __rbd_osd_setup_zeroout_ops()
2414 obj_req->ex.oe_off, obj_req->ex.oe_len, in __rbd_osd_setup_zeroout_ops()
2418 static int rbd_obj_init_zeroout(struct rbd_obj_request *obj_req) in rbd_obj_init_zeroout() argument
2423 ret = rbd_obj_calc_img_extents(obj_req, true); in rbd_obj_init_zeroout()
2427 if (!obj_req->num_img_extents) { in rbd_obj_init_zeroout()
2428 obj_req->flags |= RBD_OBJ_FLAG_NOOP_FOR_NONEXISTENT; in rbd_obj_init_zeroout()
2429 if (rbd_obj_is_entire(obj_req)) in rbd_obj_init_zeroout()
2430 obj_req->flags |= RBD_OBJ_FLAG_DELETION; in rbd_obj_init_zeroout()
2433 obj_req->write_state = RBD_OBJ_WRITE_START; in rbd_obj_init_zeroout()
2437 static int count_write_ops(struct rbd_obj_request *obj_req) in count_write_ops() argument
2439 struct rbd_img_request *img_req = obj_req->img_request; in count_write_ops()
2444 !(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST)) in count_write_ops()
2451 if (rbd_obj_is_entire(obj_req) && obj_req->num_img_extents && in count_write_ops()
2452 !(obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED)) in count_write_ops()
2464 struct rbd_obj_request *obj_req = osd_req->r_priv; in rbd_osd_setup_write_ops() local
2466 switch (obj_req->img_request->op_type) { in rbd_osd_setup_write_ops()
2488 struct rbd_obj_request *obj_req, *next_obj_req; in __rbd_img_fill_request() local
2491 for_each_obj_request_safe(img_req, obj_req, next_obj_req) { in __rbd_img_fill_request()
2494 ret = rbd_obj_init_read(obj_req); in __rbd_img_fill_request()
2497 ret = rbd_obj_init_write(obj_req); in __rbd_img_fill_request()
2500 ret = rbd_obj_init_discard(obj_req); in __rbd_img_fill_request()
2503 ret = rbd_obj_init_zeroout(obj_req); in __rbd_img_fill_request()
2511 rbd_img_obj_request_del(img_req, obj_req); in __rbd_img_fill_request()
2537 struct rbd_obj_request *obj_req; in alloc_object_extent() local
2539 obj_req = rbd_obj_request_create(); in alloc_object_extent()
2540 if (!obj_req) in alloc_object_extent()
2543 rbd_img_obj_request_add(img_req, obj_req); in alloc_object_extent()
2544 return &obj_req->ex; in alloc_object_extent()
2607 struct rbd_obj_request *obj_req; in rbd_img_fill_request() local
2637 for_each_obj_request(img_req, obj_req) { in rbd_img_fill_request()
2638 obj_req->bvec_pos.bvecs = kmalloc_array(obj_req->bvec_count, in rbd_img_fill_request()
2639 sizeof(*obj_req->bvec_pos.bvecs), in rbd_img_fill_request()
2641 if (!obj_req->bvec_pos.bvecs) in rbd_img_fill_request()
2678 struct rbd_obj_request *obj_req = in set_bio_pos() local
2683 obj_req->bio_pos = *it; in set_bio_pos()
2689 struct rbd_obj_request *obj_req = in count_bio_bvecs() local
2695 obj_req->bvec_count++; in count_bio_bvecs()
2702 struct rbd_obj_request *obj_req = in copy_bio_bvecs() local
2708 obj_req->bvec_pos.bvecs[obj_req->bvec_idx++] = bv; in copy_bio_bvecs()
2709 obj_req->bvec_pos.iter.bi_size += bv.bv_len; in copy_bio_bvecs()
2741 struct rbd_obj_request *obj_req = in set_bvec_pos() local
2745 obj_req->bvec_pos = *it; in set_bvec_pos()
2746 ceph_bvec_iter_shorten(&obj_req->bvec_pos, bytes); in set_bvec_pos()
2752 struct rbd_obj_request *obj_req = in count_bvecs() local
2757 obj_req->bvec_count++; in count_bvecs()
2763 struct rbd_obj_request *obj_req = in copy_bvecs() local
2768 obj_req->bvec_pos.bvecs[obj_req->bvec_idx++] = bv; in copy_bvecs()
2769 obj_req->bvec_pos.iter.bi_size += bv.bv_len; in copy_bvecs()
2820 static bool rbd_obj_may_exist(struct rbd_obj_request *obj_req) in rbd_obj_may_exist() argument
2822 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_may_exist()
2824 if (rbd_object_map_may_exist(rbd_dev, obj_req->ex.oe_objno)) { in rbd_obj_may_exist()
2825 obj_req->flags |= RBD_OBJ_FLAG_MAY_EXIST; in rbd_obj_may_exist()
2829 dout("%s %p objno %llu assuming dne\n", __func__, obj_req, in rbd_obj_may_exist()
2830 obj_req->ex.oe_objno); in rbd_obj_may_exist()
2834 static int rbd_obj_read_object(struct rbd_obj_request *obj_req) in rbd_obj_read_object() argument
2839 osd_req = __rbd_obj_add_osd_request(obj_req, NULL, 1); in rbd_obj_read_object()
2844 obj_req->ex.oe_off, obj_req->ex.oe_len, 0, 0); in rbd_obj_read_object()
2856 static int rbd_obj_read_from_parent(struct rbd_obj_request *obj_req) in rbd_obj_read_from_parent() argument
2858 struct rbd_img_request *img_req = obj_req->img_request; in rbd_obj_read_from_parent()
2869 child_img_req->obj_request = obj_req; in rbd_obj_read_from_parent()
2876 obj_req); in rbd_obj_read_from_parent()
2882 obj_req->img_extents, in rbd_obj_read_from_parent()
2883 obj_req->num_img_extents, in rbd_obj_read_from_parent()
2884 &obj_req->bio_pos); in rbd_obj_read_from_parent()
2889 obj_req->img_extents, in rbd_obj_read_from_parent()
2890 obj_req->num_img_extents, in rbd_obj_read_from_parent()
2891 &obj_req->bvec_pos); in rbd_obj_read_from_parent()
2898 obj_req->img_extents, in rbd_obj_read_from_parent()
2899 obj_req->num_img_extents, in rbd_obj_read_from_parent()
2900 obj_req->copyup_bvecs); in rbd_obj_read_from_parent()
2912 static bool rbd_obj_advance_read(struct rbd_obj_request *obj_req, int *result) in rbd_obj_advance_read() argument
2914 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_advance_read()
2918 switch (obj_req->read_state) { in rbd_obj_advance_read()
2922 if (!rbd_obj_may_exist(obj_req)) { in rbd_obj_advance_read()
2924 obj_req->read_state = RBD_OBJ_READ_OBJECT; in rbd_obj_advance_read()
2928 ret = rbd_obj_read_object(obj_req); in rbd_obj_advance_read()
2933 obj_req->read_state = RBD_OBJ_READ_OBJECT; in rbd_obj_advance_read()
2938 ret = rbd_obj_calc_img_extents(obj_req, false); in rbd_obj_advance_read()
2943 if (obj_req->num_img_extents) { in rbd_obj_advance_read()
2944 ret = rbd_obj_read_from_parent(obj_req); in rbd_obj_advance_read()
2949 obj_req->read_state = RBD_OBJ_READ_PARENT; in rbd_obj_advance_read()
2960 rbd_obj_zero_range(obj_req, 0, obj_req->ex.oe_len); in rbd_obj_advance_read()
2963 if (*result < obj_req->ex.oe_len) in rbd_obj_advance_read()
2964 rbd_obj_zero_range(obj_req, *result, in rbd_obj_advance_read()
2965 obj_req->ex.oe_len - *result); in rbd_obj_advance_read()
2967 rbd_assert(*result == obj_req->ex.oe_len); in rbd_obj_advance_read()
2977 u32 obj_overlap = rbd_obj_img_extents_bytes(obj_req); in rbd_obj_advance_read()
2979 if (obj_overlap < obj_req->ex.oe_len) in rbd_obj_advance_read()
2980 rbd_obj_zero_range(obj_req, obj_overlap, in rbd_obj_advance_read()
2981 obj_req->ex.oe_len - obj_overlap); in rbd_obj_advance_read()
2989 static bool rbd_obj_write_is_noop(struct rbd_obj_request *obj_req) in rbd_obj_write_is_noop() argument
2991 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_write_is_noop()
2993 if (rbd_object_map_may_exist(rbd_dev, obj_req->ex.oe_objno)) in rbd_obj_write_is_noop()
2994 obj_req->flags |= RBD_OBJ_FLAG_MAY_EXIST; in rbd_obj_write_is_noop()
2996 if (!(obj_req->flags & RBD_OBJ_FLAG_MAY_EXIST) && in rbd_obj_write_is_noop()
2997 (obj_req->flags & RBD_OBJ_FLAG_NOOP_FOR_NONEXISTENT)) { in rbd_obj_write_is_noop()
2998 dout("%s %p noop for nonexistent\n", __func__, obj_req); in rbd_obj_write_is_noop()
3011 static int rbd_obj_write_pre_object_map(struct rbd_obj_request *obj_req) in rbd_obj_write_pre_object_map() argument
3013 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_write_pre_object_map()
3019 if (obj_req->flags & RBD_OBJ_FLAG_DELETION) in rbd_obj_write_pre_object_map()
3024 return rbd_object_map_update(obj_req, CEPH_NOSNAP, new_state, NULL); in rbd_obj_write_pre_object_map()
3027 static int rbd_obj_write_object(struct rbd_obj_request *obj_req) in rbd_obj_write_object() argument
3030 int num_ops = count_write_ops(obj_req); in rbd_obj_write_object()
3034 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED) in rbd_obj_write_object()
3037 osd_req = rbd_obj_add_osd_request(obj_req, num_ops); in rbd_obj_write_object()
3041 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED) { in rbd_obj_write_object()
3078 static int rbd_obj_copyup_empty_snapc(struct rbd_obj_request *obj_req, in rbd_obj_copyup_empty_snapc() argument
3084 dout("%s obj_req %p bytes %u\n", __func__, obj_req, bytes); in rbd_obj_copyup_empty_snapc()
3087 osd_req = __rbd_obj_add_osd_request(obj_req, &rbd_empty_snapc, 1); in rbd_obj_copyup_empty_snapc()
3105 static int rbd_obj_copyup_current_snapc(struct rbd_obj_request *obj_req, in rbd_obj_copyup_current_snapc() argument
3109 int num_ops = count_write_ops(obj_req); in rbd_obj_copyup_current_snapc()
3113 dout("%s obj_req %p bytes %u\n", __func__, obj_req, bytes); in rbd_obj_copyup_current_snapc()
3118 osd_req = rbd_obj_add_osd_request(obj_req, num_ops); in rbd_obj_copyup_current_snapc()
3139 static int setup_copyup_bvecs(struct rbd_obj_request *obj_req, u64 obj_overlap) in setup_copyup_bvecs() argument
3143 rbd_assert(!obj_req->copyup_bvecs); in setup_copyup_bvecs()
3144 obj_req->copyup_bvec_count = calc_pages_for(0, obj_overlap); in setup_copyup_bvecs()
3145 obj_req->copyup_bvecs = kcalloc(obj_req->copyup_bvec_count, in setup_copyup_bvecs()
3146 sizeof(*obj_req->copyup_bvecs), in setup_copyup_bvecs()
3148 if (!obj_req->copyup_bvecs) in setup_copyup_bvecs()
3151 for (i = 0; i < obj_req->copyup_bvec_count; i++) { in setup_copyup_bvecs()
3154 obj_req->copyup_bvecs[i].bv_page = alloc_page(GFP_NOIO); in setup_copyup_bvecs()
3155 if (!obj_req->copyup_bvecs[i].bv_page) in setup_copyup_bvecs()
3158 obj_req->copyup_bvecs[i].bv_offset = 0; in setup_copyup_bvecs()
3159 obj_req->copyup_bvecs[i].bv_len = len; in setup_copyup_bvecs()
3172 static int rbd_obj_copyup_read_parent(struct rbd_obj_request *obj_req) in rbd_obj_copyup_read_parent() argument
3174 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_copyup_read_parent()
3177 rbd_assert(obj_req->num_img_extents); in rbd_obj_copyup_read_parent()
3178 prune_extents(obj_req->img_extents, &obj_req->num_img_extents, in rbd_obj_copyup_read_parent()
3180 if (!obj_req->num_img_extents) { in rbd_obj_copyup_read_parent()
3187 return rbd_obj_copyup_current_snapc(obj_req, MODS_ONLY); in rbd_obj_copyup_read_parent()
3190 ret = setup_copyup_bvecs(obj_req, rbd_obj_img_extents_bytes(obj_req)); in rbd_obj_copyup_read_parent()
3194 return rbd_obj_read_from_parent(obj_req); in rbd_obj_copyup_read_parent()
3197 static void rbd_obj_copyup_object_maps(struct rbd_obj_request *obj_req) in rbd_obj_copyup_object_maps() argument
3199 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_copyup_object_maps()
3200 struct ceph_snap_context *snapc = obj_req->img_request->snapc; in rbd_obj_copyup_object_maps()
3205 rbd_assert(!obj_req->pending.result && !obj_req->pending.num_pending); in rbd_obj_copyup_object_maps()
3210 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ZEROS) in rbd_obj_copyup_object_maps()
3220 ret = rbd_object_map_update(obj_req, snapc->snaps[i], in rbd_obj_copyup_object_maps()
3223 obj_req->pending.result = ret; in rbd_obj_copyup_object_maps()
3228 obj_req->pending.num_pending++; in rbd_obj_copyup_object_maps()
3232 static void rbd_obj_copyup_write_object(struct rbd_obj_request *obj_req) in rbd_obj_copyup_write_object() argument
3234 u32 bytes = rbd_obj_img_extents_bytes(obj_req); in rbd_obj_copyup_write_object()
3237 rbd_assert(!obj_req->pending.result && !obj_req->pending.num_pending); in rbd_obj_copyup_write_object()
3244 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ZEROS) in rbd_obj_copyup_write_object()
3247 if (obj_req->img_request->snapc->num_snaps && bytes > 0) { in rbd_obj_copyup_write_object()
3254 ret = rbd_obj_copyup_empty_snapc(obj_req, bytes); in rbd_obj_copyup_write_object()
3256 obj_req->pending.result = ret; in rbd_obj_copyup_write_object()
3260 obj_req->pending.num_pending++; in rbd_obj_copyup_write_object()
3264 ret = rbd_obj_copyup_current_snapc(obj_req, bytes); in rbd_obj_copyup_write_object()
3266 obj_req->pending.result = ret; in rbd_obj_copyup_write_object()
3270 obj_req->pending.num_pending++; in rbd_obj_copyup_write_object()
3273 static bool rbd_obj_advance_copyup(struct rbd_obj_request *obj_req, int *result) in rbd_obj_advance_copyup() argument
3275 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_advance_copyup()
3279 switch (obj_req->copyup_state) { in rbd_obj_advance_copyup()
3283 ret = rbd_obj_copyup_read_parent(obj_req); in rbd_obj_advance_copyup()
3288 if (obj_req->num_img_extents) in rbd_obj_advance_copyup()
3289 obj_req->copyup_state = RBD_OBJ_COPYUP_READ_PARENT; in rbd_obj_advance_copyup()
3291 obj_req->copyup_state = RBD_OBJ_COPYUP_WRITE_OBJECT; in rbd_obj_advance_copyup()
3297 if (is_zero_bvecs(obj_req->copyup_bvecs, in rbd_obj_advance_copyup()
3298 rbd_obj_img_extents_bytes(obj_req))) { in rbd_obj_advance_copyup()
3299 dout("%s %p detected zeros\n", __func__, obj_req); in rbd_obj_advance_copyup()
3300 obj_req->flags |= RBD_OBJ_FLAG_COPYUP_ZEROS; in rbd_obj_advance_copyup()
3303 rbd_obj_copyup_object_maps(obj_req); in rbd_obj_advance_copyup()
3304 if (!obj_req->pending.num_pending) { in rbd_obj_advance_copyup()
3305 *result = obj_req->pending.result; in rbd_obj_advance_copyup()
3306 obj_req->copyup_state = RBD_OBJ_COPYUP_OBJECT_MAPS; in rbd_obj_advance_copyup()
3309 obj_req->copyup_state = __RBD_OBJ_COPYUP_OBJECT_MAPS; in rbd_obj_advance_copyup()
3312 if (!pending_result_dec(&obj_req->pending, result)) in rbd_obj_advance_copyup()
3322 rbd_obj_copyup_write_object(obj_req); in rbd_obj_advance_copyup()
3323 if (!obj_req->pending.num_pending) { in rbd_obj_advance_copyup()
3324 *result = obj_req->pending.result; in rbd_obj_advance_copyup()
3325 obj_req->copyup_state = RBD_OBJ_COPYUP_WRITE_OBJECT; in rbd_obj_advance_copyup()
3328 obj_req->copyup_state = __RBD_OBJ_COPYUP_WRITE_OBJECT; in rbd_obj_advance_copyup()
3331 if (!pending_result_dec(&obj_req->pending, result)) in rbd_obj_advance_copyup()
3347 static int rbd_obj_write_post_object_map(struct rbd_obj_request *obj_req) in rbd_obj_write_post_object_map() argument
3349 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_write_post_object_map()
3355 if (!(obj_req->flags & RBD_OBJ_FLAG_DELETION)) in rbd_obj_write_post_object_map()
3358 return rbd_object_map_update(obj_req, CEPH_NOSNAP, OBJECT_NONEXISTENT, in rbd_obj_write_post_object_map()
3362 static bool rbd_obj_advance_write(struct rbd_obj_request *obj_req, int *result) in rbd_obj_advance_write() argument
3364 struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; in rbd_obj_advance_write()
3368 switch (obj_req->write_state) { in rbd_obj_advance_write()
3372 rbd_obj_set_copyup_enabled(obj_req); in rbd_obj_advance_write()
3373 if (rbd_obj_write_is_noop(obj_req)) in rbd_obj_advance_write()
3376 ret = rbd_obj_write_pre_object_map(obj_req); in rbd_obj_advance_write()
3381 obj_req->write_state = RBD_OBJ_WRITE_PRE_OBJECT_MAP; in rbd_obj_advance_write()
3391 ret = rbd_obj_write_object(obj_req); in rbd_obj_advance_write()
3396 obj_req->write_state = RBD_OBJ_WRITE_OBJECT; in rbd_obj_advance_write()
3400 if (obj_req->flags & RBD_OBJ_FLAG_COPYUP_ENABLED) { in rbd_obj_advance_write()
3402 obj_req->copyup_state = RBD_OBJ_COPYUP_START; in rbd_obj_advance_write()
3403 obj_req->write_state = __RBD_OBJ_WRITE_COPYUP; in rbd_obj_advance_write()
3410 if (obj_req->flags & RBD_OBJ_FLAG_DELETION) in rbd_obj_advance_write()
3416 obj_req->write_state = RBD_OBJ_WRITE_COPYUP; in rbd_obj_advance_write()
3419 if (!rbd_obj_advance_copyup(obj_req, result)) in rbd_obj_advance_write()
3427 ret = rbd_obj_write_post_object_map(obj_req); in rbd_obj_advance_write()
3432 obj_req->write_state = RBD_OBJ_WRITE_POST_OBJECT_MAP; in rbd_obj_advance_write()
3449 static bool __rbd_obj_handle_request(struct rbd_obj_request *obj_req, in __rbd_obj_handle_request() argument
3452 struct rbd_img_request *img_req = obj_req->img_request; in __rbd_obj_handle_request()
3456 mutex_lock(&obj_req->state_mutex); in __rbd_obj_handle_request()
3458 done = rbd_obj_advance_read(obj_req, result); in __rbd_obj_handle_request()
3460 done = rbd_obj_advance_write(obj_req, result); in __rbd_obj_handle_request()
3461 mutex_unlock(&obj_req->state_mutex); in __rbd_obj_handle_request()
3466 obj_op_name(img_req->op_type), obj_req->ex.oe_objno, in __rbd_obj_handle_request()
3467 obj_req->ex.oe_off, obj_req->ex.oe_len, *result); in __rbd_obj_handle_request()
3476 static void rbd_obj_handle_request(struct rbd_obj_request *obj_req, int result) in rbd_obj_handle_request() argument
3478 if (__rbd_obj_handle_request(obj_req, &result)) in rbd_obj_handle_request()
3479 rbd_img_handle_request(obj_req->img_request, result); in rbd_obj_handle_request()
3561 struct rbd_obj_request *obj_req; in rbd_img_object_requests() local
3574 for_each_obj_request(img_req, obj_req) { in rbd_img_object_requests()
3577 if (__rbd_obj_handle_request(obj_req, &result)) { in rbd_img_object_requests()
3668 struct rbd_obj_request *obj_req = img_req->obj_request; in rbd_img_handle_request() local
3671 if (__rbd_obj_handle_request(obj_req, &result)) { in rbd_img_handle_request()
3672 img_req = obj_req->img_request; in rbd_img_handle_request()