Skip to contentSkip to conversation

libceph: Call con->ops->put(con) if cancel_delayed_work(&con->work) worked.

PATCH In review majianpeng 2 participants 2 messages Jun 24, 2013 Ceph common code (libceph)

lore
Share & tools
lore

majianpeng

author
#0 lore raw

PATCH 1/1 libceph: Call con->ops->put(con) if cancel_delayed_work(&con->work) worked.

Because in func queue_con_delay, it will call con->ops->get(con). So if we cancel the work successfully,we must call con->ops->put(con). Otherwise some resource can't free like 'struct ceph_mds_session'.

---
 net/ceph/messenger.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/ceph/messenger.c +2 -1
index eb0a46a..8207b37 100644
@@ -661,7 +661,8 @@ void ceph_con_close(struct ceph_connection *con)
 
 	reset_connection(con);
 	con->peer_global_seq = 0;
-	cancel_delayed_work(&con->work);
+	if (cancel_delayed_work(&con->work))
+		con->ops->put(con);
 	con_close_socket(con);
 	mutex_unlock(&con->mutex);
 }
Signature · 1 line
1.8.1.2
#1 lore raw
Quoted 5 lines · majianpeng

Because in func queue_con_delay, it will call con->ops->get(con). So if we cancel the work successfully,we must call con->ops->put(con). Otherwise some resource can't free like 'struct ceph_mds_session'.

Looks good, applied to the testing branch.

Thanks!
sage

Quoted 21 lines
---
 net/ceph/messenger.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/ceph/messenger.c +2 -1
index eb0a46a..8207b37 100644
@@ -661,7 +661,8 @@ void ceph_con_close(struct ceph_connection *con)
 
 	reset_connection(con);
 	con->peer_global_seq = 0;
-	cancel_delayed_work(&con->work);
+	if (cancel_delayed_work(&con->work))
+		con->ops->put(con);
 	con_close_socket(con);
 	mutex_unlock(&con->mutex);
 }
Signature · 1 line
1.8.1.2