@@ -362,7 +362,7 @@ enum rbd_watch_state {
362362enum rbd_lock_state {
363363 RBD_LOCK_STATE_UNLOCKED ,
364364 RBD_LOCK_STATE_LOCKED ,
365- RBD_LOCK_STATE_RELEASING ,
365+ RBD_LOCK_STATE_QUIESCING ,
366366};
367367
368368/* WatchNotify::ClientId */
@@ -422,7 +422,7 @@ struct rbd_device {
422422 struct list_head running_list ;
423423 struct completion acquire_wait ;
424424 int acquire_err ;
425- struct completion releasing_wait ;
425+ struct completion quiescing_wait ;
426426
427427 spinlock_t object_map_lock ;
428428 u8 * object_map ;
@@ -525,7 +525,7 @@ static bool __rbd_is_lock_owner(struct rbd_device *rbd_dev)
525525 lockdep_assert_held (& rbd_dev -> lock_rwsem );
526526
527527 return rbd_dev -> lock_state == RBD_LOCK_STATE_LOCKED ||
528- rbd_dev -> lock_state == RBD_LOCK_STATE_RELEASING ;
528+ rbd_dev -> lock_state == RBD_LOCK_STATE_QUIESCING ;
529529}
530530
531531static bool rbd_is_lock_owner (struct rbd_device * rbd_dev )
@@ -3457,13 +3457,14 @@ static void rbd_lock_del_request(struct rbd_img_request *img_req)
34573457 lockdep_assert_held (& rbd_dev -> lock_rwsem );
34583458 spin_lock (& rbd_dev -> lock_lists_lock );
34593459 if (!list_empty (& img_req -> lock_item )) {
3460+ rbd_assert (!list_empty (& rbd_dev -> running_list ));
34603461 list_del_init (& img_req -> lock_item );
3461- need_wakeup = (rbd_dev -> lock_state == RBD_LOCK_STATE_RELEASING &&
3462+ need_wakeup = (rbd_dev -> lock_state == RBD_LOCK_STATE_QUIESCING &&
34623463 list_empty (& rbd_dev -> running_list ));
34633464 }
34643465 spin_unlock (& rbd_dev -> lock_lists_lock );
34653466 if (need_wakeup )
3466- complete (& rbd_dev -> releasing_wait );
3467+ complete (& rbd_dev -> quiescing_wait );
34673468}
34683469
34693470static int rbd_img_exclusive_lock (struct rbd_img_request * img_req )
@@ -3476,11 +3477,6 @@ static int rbd_img_exclusive_lock(struct rbd_img_request *img_req)
34763477 if (rbd_lock_add_request (img_req ))
34773478 return 1 ;
34783479
3479- if (rbd_dev -> opts -> exclusive ) {
3480- WARN_ON (1 ); /* lock got released? */
3481- return - EROFS ;
3482- }
3483-
34843480 /*
34853481 * Note the use of mod_delayed_work() in rbd_acquire_lock()
34863482 * and cancel_delayed_work() in wake_lock_waiters().
@@ -4181,16 +4177,16 @@ static bool rbd_quiesce_lock(struct rbd_device *rbd_dev)
41814177 /*
41824178 * Ensure that all in-flight IO is flushed.
41834179 */
4184- rbd_dev -> lock_state = RBD_LOCK_STATE_RELEASING ;
4185- rbd_assert (!completion_done (& rbd_dev -> releasing_wait ));
4180+ rbd_dev -> lock_state = RBD_LOCK_STATE_QUIESCING ;
4181+ rbd_assert (!completion_done (& rbd_dev -> quiescing_wait ));
41864182 if (list_empty (& rbd_dev -> running_list ))
41874183 return true;
41884184
41894185 up_write (& rbd_dev -> lock_rwsem );
4190- wait_for_completion (& rbd_dev -> releasing_wait );
4186+ wait_for_completion (& rbd_dev -> quiescing_wait );
41914187
41924188 down_write (& rbd_dev -> lock_rwsem );
4193- if (rbd_dev -> lock_state != RBD_LOCK_STATE_RELEASING )
4189+ if (rbd_dev -> lock_state != RBD_LOCK_STATE_QUIESCING )
41944190 return false;
41954191
41964192 rbd_assert (list_empty (& rbd_dev -> running_list ));
@@ -4601,6 +4597,10 @@ static void rbd_reacquire_lock(struct rbd_device *rbd_dev)
46014597 rbd_warn (rbd_dev , "failed to update lock cookie: %d" ,
46024598 ret );
46034599
4600+ if (rbd_dev -> opts -> exclusive )
4601+ rbd_warn (rbd_dev ,
4602+ "temporarily releasing lock on exclusive mapping" );
4603+
46044604 /*
46054605 * Lock cookie cannot be updated on older OSDs, so do
46064606 * a manual release and queue an acquire.
@@ -5376,7 +5376,7 @@ static struct rbd_device *__rbd_dev_create(struct rbd_spec *spec)
53765376 INIT_LIST_HEAD (& rbd_dev -> acquiring_list );
53775377 INIT_LIST_HEAD (& rbd_dev -> running_list );
53785378 init_completion (& rbd_dev -> acquire_wait );
5379- init_completion (& rbd_dev -> releasing_wait );
5379+ init_completion (& rbd_dev -> quiescing_wait );
53805380
53815381 spin_lock_init (& rbd_dev -> object_map_lock );
53825382
@@ -6582,11 +6582,6 @@ static int rbd_add_acquire_lock(struct rbd_device *rbd_dev)
65826582 if (ret )
65836583 return ret ;
65846584
6585- /*
6586- * The lock may have been released by now, unless automatic lock
6587- * transitions are disabled.
6588- */
6589- rbd_assert (!rbd_dev -> opts -> exclusive || rbd_is_lock_owner (rbd_dev ));
65906585 return 0 ;
65916586}
65926587
0 commit comments