Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit edd8ca80 authored by Florian Margaine's avatar Florian Margaine Committed by Ilya Dryomov
Browse files

rbd: reacquire lock should update lock owner client id

Otherwise, future operations on this RBD using exclusive-lock are
going to require the lock from a non-existent client id.

Cc: stable@vger.kernel.org
Fixes: 14bb211d ("rbd: support updating the lock cookie without releasing the lock")
Link: http://tracker.ceph.com/issues/19929


Signed-off-by: default avatarFlorian Margaine <florian@platform.sh>
[idryomov@gmail.com: rbd_set_owner_cid() call, __rbd_lock() helper]
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent b2cd1df6
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -3047,13 +3047,21 @@ static void format_lock_cookie(struct rbd_device *rbd_dev, char *buf)
	mutex_unlock(&rbd_dev->watch_mutex);
}

static void __rbd_lock(struct rbd_device *rbd_dev, const char *cookie)
{
	struct rbd_client_id cid = rbd_get_cid(rbd_dev);

	strcpy(rbd_dev->lock_cookie, cookie);
	rbd_set_owner_cid(rbd_dev, &cid);
	queue_work(rbd_dev->task_wq, &rbd_dev->acquired_lock_work);
}

/*
 * lock_rwsem must be held for write
 */
static int rbd_lock(struct rbd_device *rbd_dev)
{
	struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc;
	struct rbd_client_id cid = rbd_get_cid(rbd_dev);
	char cookie[32];
	int ret;

@@ -3068,9 +3076,7 @@ static int rbd_lock(struct rbd_device *rbd_dev)
		return ret;

	rbd_dev->lock_state = RBD_LOCK_STATE_LOCKED;
	strcpy(rbd_dev->lock_cookie, cookie);
	rbd_set_owner_cid(rbd_dev, &cid);
	queue_work(rbd_dev->task_wq, &rbd_dev->acquired_lock_work);
	__rbd_lock(rbd_dev, cookie);
	return 0;
}

@@ -3856,7 +3862,7 @@ static void rbd_reacquire_lock(struct rbd_device *rbd_dev)
			queue_delayed_work(rbd_dev->task_wq,
					   &rbd_dev->lock_dwork, 0);
	} else {
		strcpy(rbd_dev->lock_cookie, cookie);
		__rbd_lock(rbd_dev, cookie);
	}
}