Skip to content

Commit 6098d87

Browse files
committed
Merge tag 'ceph-for-6.8-rc2' of https://github.com/ceph/ceph-client
Pull ceph fixes from Ilya Dryomov: "A fix to avoid triggering an assert in some cases where RBD exclusive mappings are involved and a deprecated API cleanup" * tag 'ceph-for-6.8-rc2' of https://github.com/ceph/ceph-client: rbd: don't move requests to the running list on errors rbd: remove usage of the deprecated ida_simple_*() API
2 parents f22face + ded080c commit 6098d87

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

drivers/block/rbd.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3452,14 +3452,15 @@ static bool rbd_lock_add_request(struct rbd_img_request *img_req)
34523452
static void rbd_lock_del_request(struct rbd_img_request *img_req)
34533453
{
34543454
struct rbd_device *rbd_dev = img_req->rbd_dev;
3455-
bool need_wakeup;
3455+
bool need_wakeup = false;
34563456

34573457
lockdep_assert_held(&rbd_dev->lock_rwsem);
34583458
spin_lock(&rbd_dev->lock_lists_lock);
3459-
rbd_assert(!list_empty(&img_req->lock_item));
3460-
list_del_init(&img_req->lock_item);
3461-
need_wakeup = (rbd_dev->lock_state == RBD_LOCK_STATE_RELEASING &&
3462-
list_empty(&rbd_dev->running_list));
3459+
if (!list_empty(&img_req->lock_item)) {
3460+
list_del_init(&img_req->lock_item);
3461+
need_wakeup = (rbd_dev->lock_state == RBD_LOCK_STATE_RELEASING &&
3462+
list_empty(&rbd_dev->running_list));
3463+
}
34633464
spin_unlock(&rbd_dev->lock_lists_lock);
34643465
if (need_wakeup)
34653466
complete(&rbd_dev->releasing_wait);
@@ -3842,14 +3843,19 @@ static void wake_lock_waiters(struct rbd_device *rbd_dev, int result)
38423843
return;
38433844
}
38443845

3845-
list_for_each_entry(img_req, &rbd_dev->acquiring_list, lock_item) {
3846+
while (!list_empty(&rbd_dev->acquiring_list)) {
3847+
img_req = list_first_entry(&rbd_dev->acquiring_list,
3848+
struct rbd_img_request, lock_item);
38463849
mutex_lock(&img_req->state_mutex);
38473850
rbd_assert(img_req->state == RBD_IMG_EXCLUSIVE_LOCK);
3851+
if (!result)
3852+
list_move_tail(&img_req->lock_item,
3853+
&rbd_dev->running_list);
3854+
else
3855+
list_del_init(&img_req->lock_item);
38483856
rbd_img_schedule(img_req, result);
38493857
mutex_unlock(&img_req->state_mutex);
38503858
}
3851-
3852-
list_splice_tail_init(&rbd_dev->acquiring_list, &rbd_dev->running_list);
38533859
}
38543860

38553861
static bool locker_equal(const struct ceph_locker *lhs,
@@ -5326,7 +5332,7 @@ static void rbd_dev_release(struct device *dev)
53265332

53275333
if (need_put) {
53285334
destroy_workqueue(rbd_dev->task_wq);
5329-
ida_simple_remove(&rbd_dev_id_ida, rbd_dev->dev_id);
5335+
ida_free(&rbd_dev_id_ida, rbd_dev->dev_id);
53305336
}
53315337

53325338
rbd_dev_free(rbd_dev);
@@ -5402,9 +5408,9 @@ static struct rbd_device *rbd_dev_create(struct rbd_client *rbdc,
54025408
return NULL;
54035409

54045410
/* get an id and fill in device name */
5405-
rbd_dev->dev_id = ida_simple_get(&rbd_dev_id_ida, 0,
5406-
minor_to_rbd_dev_id(1 << MINORBITS),
5407-
GFP_KERNEL);
5411+
rbd_dev->dev_id = ida_alloc_max(&rbd_dev_id_ida,
5412+
minor_to_rbd_dev_id(1 << MINORBITS) - 1,
5413+
GFP_KERNEL);
54085414
if (rbd_dev->dev_id < 0)
54095415
goto fail_rbd_dev;
54105416

@@ -5425,7 +5431,7 @@ static struct rbd_device *rbd_dev_create(struct rbd_client *rbdc,
54255431
return rbd_dev;
54265432

54275433
fail_dev_id:
5428-
ida_simple_remove(&rbd_dev_id_ida, rbd_dev->dev_id);
5434+
ida_free(&rbd_dev_id_ida, rbd_dev->dev_id);
54295435
fail_rbd_dev:
54305436
rbd_dev_free(rbd_dev);
54315437
return NULL;

0 commit comments

Comments
 (0)