Lines Matching defs:img_req

644 static void rbd_img_handle_request(struct rbd_img_request *img_req, int result);
1372 static bool rbd_img_is_write(struct rbd_img_request *img_req)
1374 switch (img_req->op_type) {
1606 static void rbd_img_capture_header(struct rbd_img_request *img_req)
1608 struct rbd_device *rbd_dev = img_req->rbd_dev;
1612 if (!rbd_img_is_write(img_req))
1613 img_req->snap_id = rbd_dev->spec->snap_id;
1616 img_request_layered_set(img_req);
2376 struct rbd_img_request *img_req = obj_req->img_request;
2378 switch (img_req->op_type) {
2380 if (!use_object_map(img_req->rbd_dev) ||
2423 static int __rbd_img_fill_request(struct rbd_img_request *img_req)
2428 for_each_obj_request_safe(img_req, obj_req, next_obj_req) {
2429 switch (img_req->op_type) {
2448 rbd_img_obj_request_del(img_req, obj_req);
2453 img_req->state = RBD_IMG_START;
2473 struct rbd_img_request *img_req = arg;
2480 rbd_img_obj_request_add(img_req, obj_req);
2496 static int rbd_img_fill_request_nocopy(struct rbd_img_request *img_req,
2504 img_req->data_type = fctx->pos_type;
2512 ret = ceph_file_to_extents(&img_req->rbd_dev->layout,
2515 &img_req->object_extents,
2516 alloc_object_extent, img_req,
2522 return __rbd_img_fill_request(img_req);
2528 * but not always) and add them to @img_req. For each object request,
2538 static int rbd_img_fill_request(struct rbd_img_request *img_req,
2543 struct rbd_device *rbd_dev = img_req->rbd_dev;
2550 return rbd_img_fill_request_nocopy(img_req, img_extents,
2553 img_req->data_type = OBJ_REQUEST_OWN_BVECS;
2567 &img_req->object_extents,
2568 alloc_object_extent, img_req,
2574 for_each_obj_request(img_req, obj_req) {
2591 &img_req->object_extents,
2597 return __rbd_img_fill_request(img_req);
2600 static int rbd_img_fill_nodata(struct rbd_img_request *img_req,
2610 return rbd_img_fill_request(img_req, &ex, 1, &fctx);
2650 static int __rbd_img_fill_from_bio(struct rbd_img_request *img_req,
2663 return rbd_img_fill_request(img_req, img_extents, num_img_extents,
2667 static int rbd_img_fill_from_bio(struct rbd_img_request *img_req,
2673 return __rbd_img_fill_from_bio(img_req, &ex, 1, &it);
2710 static int __rbd_img_fill_from_bvecs(struct rbd_img_request *img_req,
2723 return rbd_img_fill_request(img_req, img_extents, num_img_extents,
2727 static int rbd_img_fill_from_bvecs(struct rbd_img_request *img_req,
2738 return __rbd_img_fill_from_bvecs(img_req, img_extents, num_img_extents,
2744 struct rbd_img_request *img_req =
2747 rbd_img_handle_request(img_req, img_req->work_result);
2750 static void rbd_img_schedule(struct rbd_img_request *img_req, int result)
2752 INIT_WORK(&img_req->work, rbd_img_handle_request_work);
2753 img_req->work_result = result;
2754 queue_work(rbd_wq, &img_req->work);
2795 struct rbd_img_request *img_req = obj_req->img_request;
2796 struct rbd_device *parent = img_req->rbd_dev->parent;
2815 if (!rbd_img_is_write(img_req)) {
2816 switch (img_req->data_type) {
3387 struct rbd_img_request *img_req = obj_req->img_request;
3388 struct rbd_device *rbd_dev = img_req->rbd_dev;
3392 if (!rbd_img_is_write(img_req))
3401 obj_op_name(img_req->op_type), obj_req->ex.oe_objno,
3417 static bool need_exclusive_lock(struct rbd_img_request *img_req)
3419 struct rbd_device *rbd_dev = img_req->rbd_dev;
3427 rbd_assert(!test_bit(IMG_REQ_CHILD, &img_req->flags));
3432 return rbd_img_is_write(img_req);
3435 static bool rbd_lock_add_request(struct rbd_img_request *img_req)
3437 struct rbd_device *rbd_dev = img_req->rbd_dev;
3443 rbd_assert(list_empty(&img_req->lock_item));
3445 list_add_tail(&img_req->lock_item, &rbd_dev->acquiring_list);
3447 list_add_tail(&img_req->lock_item, &rbd_dev->running_list);
3452 static void rbd_lock_del_request(struct rbd_img_request *img_req)
3454 struct rbd_device *rbd_dev = img_req->rbd_dev;
3459 if (!list_empty(&img_req->lock_item)) {
3460 list_del_init(&img_req->lock_item);
3469 static int rbd_img_exclusive_lock(struct rbd_img_request *img_req)
3471 struct rbd_device *rbd_dev = img_req->rbd_dev;
3473 if (!need_exclusive_lock(img_req))
3476 if (rbd_lock_add_request(img_req))
3493 static void rbd_img_object_requests(struct rbd_img_request *img_req)
3495 struct rbd_device *rbd_dev = img_req->rbd_dev;
3498 rbd_assert(!img_req->pending.result && !img_req->pending.num_pending);
3499 rbd_assert(!need_exclusive_lock(img_req) ||
3502 if (rbd_img_is_write(img_req)) {
3503 rbd_assert(!img_req->snapc);
3505 img_req->snapc = ceph_get_snap_context(rbd_dev->header.snapc);
3509 for_each_obj_request(img_req, obj_req) {
3514 img_req->pending.result = result;
3518 img_req->pending.num_pending++;
3523 static bool rbd_img_advance(struct rbd_img_request *img_req, int *result)
3528 switch (img_req->state) {
3532 ret = rbd_img_exclusive_lock(img_req);
3537 img_req->state = RBD_IMG_EXCLUSIVE_LOCK;
3545 rbd_img_object_requests(img_req);
3546 if (!img_req->pending.num_pending) {
3547 *result = img_req->pending.result;
3548 img_req->state = RBD_IMG_OBJECT_REQUESTS;
3551 img_req->state = __RBD_IMG_OBJECT_REQUESTS;
3554 if (!pending_result_dec(&img_req->pending, result))
3565 * Return true if @img_req is completed.
3567 static bool __rbd_img_handle_request(struct rbd_img_request *img_req,
3570 struct rbd_device *rbd_dev = img_req->rbd_dev;
3573 if (need_exclusive_lock(img_req)) {
3575 mutex_lock(&img_req->state_mutex);
3576 done = rbd_img_advance(img_req, result);
3578 rbd_lock_del_request(img_req);
3579 mutex_unlock(&img_req->state_mutex);
3582 mutex_lock(&img_req->state_mutex);
3583 done = rbd_img_advance(img_req, result);
3584 mutex_unlock(&img_req->state_mutex);
3590 test_bit(IMG_REQ_CHILD, &img_req->flags) ? "child " : "",
3591 obj_op_name(img_req->op_type), *result);
3596 static void rbd_img_handle_request(struct rbd_img_request *img_req, int result)
3599 if (!__rbd_img_handle_request(img_req, &result))
3602 if (test_bit(IMG_REQ_CHILD, &img_req->flags)) {
3603 struct rbd_obj_request *obj_req = img_req->obj_request;
3605 rbd_img_request_destroy(img_req);
3607 img_req = obj_req->img_request;
3611 struct request *rq = blk_mq_rq_from_pdu(img_req);
3613 rbd_img_request_destroy(img_req);
3832 struct rbd_img_request *img_req;
3847 img_req = list_first_entry(&rbd_dev->acquiring_list,
3849 mutex_lock(&img_req->state_mutex);
3850 rbd_assert(img_req->state == RBD_IMG_EXCLUSIVE_LOCK);
3852 list_move_tail(&img_req->lock_item,
3855 list_del_init(&img_req->lock_item);
3856 rbd_img_schedule(img_req, result);
3857 mutex_unlock(&img_req->state_mutex);
4752 dout("%s rbd_dev %p img_req %p %s %llu~%llu\n", __func__, rbd_dev,
4778 struct rbd_img_request *img_req = blk_mq_rq_to_pdu(bd->rq);
4799 rbd_img_request_init(img_req, rbd_dev, op_type);
4801 if (rbd_img_is_write(img_req)) {
4804 obj_op_name(img_req->op_type));
4810 INIT_WORK(&img_req->work, rbd_queue_workfn);
4811 queue_work(rbd_wq, &img_req->work);