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

Commit b5d91704 authored by Ilya Dryomov's avatar Ilya Dryomov
Browse files

libceph: behave in mon_fault() if cur_mon < 0



This can happen if __close_session() in ceph_monc_stop() races with
a connection reset.  We need to ignore such faults, otherwise it's
likely we would take !hunting, call __schedule_delayed() and end up
with delayed_work() executing on invalid memory, among other things.

The (two!) con->private tests are useless, as nothing ever clears
con->private.  Nuke them.

Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent bee3a37c
Loading
Loading
Loading
Loading
+9 −14
Original line number Diff line number Diff line
@@ -1155,14 +1155,9 @@ static void mon_fault(struct ceph_connection *con)
{
	struct ceph_mon_client *monc = con->private;

	if (!monc)
		return;

	dout("mon_fault\n");
	mutex_lock(&monc->mutex);
	if (!con->private)
		goto out;

	dout("%s mon%d\n", __func__, monc->cur_mon);
	if (monc->cur_mon >= 0) {
		if (!monc->hunting) {
			dout("%s hunting for new mon\n", __func__);
			reopen_session(monc);
@@ -1170,7 +1165,7 @@ static void mon_fault(struct ceph_connection *con)
		} else {
			dout("%s already hunting\n", __func__);
		}
out:
	}
	mutex_unlock(&monc->mutex);
}