Skip to contentSkip to conversation

ceph: fix request refcount leak when session can't be acquired

PATCH In review Jeff Layton 2 participants 2 messages Apr 22, 2022 – Apr 24, 2022 Ceph client

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: fix request refcount leak when session can't be acquired

...in flush_mdlog_and_wait_mdsc_unsafe_requests.

URL: https://tracker.ceph.com/issues/55411

Fixes 86bc9a732b7f ("ceph: flush the mdlog for filesystem sync")
---
 fs/ceph/mds_client.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Xiubo, feel free to fold this into the original patch so we can avoid the regression.

fs/ceph/mds_client.c +5 -7
index 2f17ca3c10b1..1e7df3b2dffd 100644
@@ -4790,18 +4790,16 @@ static void flush_mdlog_and_wait_mdsc_unsafe_requests(struct ceph_mds_client *md
 			nextreq = NULL;
 		if (req->r_op != CEPH_MDS_OP_SETFILELOCK &&
 		    (req->r_op & CEPH_MDS_OP_WRITE)) {
-			struct ceph_mds_session *s;
+			struct ceph_mds_session *s = req->r_session;
 
-			/* write op */
-			ceph_mdsc_get_request(req);
-			if (nextreq)
-				ceph_mdsc_get_request(nextreq);
-
-			s = req->r_session;
 			if (!s) {
 				req = nextreq;
 				continue;
 			}
+
+			ceph_mdsc_get_request(req);
+			if (nextreq)
+				ceph_mdsc_get_request(nextreq);
 			s = ceph_get_mds_session(s);
 			mutex_unlock(&mdsc->mutex);
 
Signature · 1 line
2.35.1
#1 lore raw
Quoted 30 lines · Jeff Layton

...in flush_mdlog_and_wait_mdsc_unsafe_requests.

URL: https://tracker.ceph.com/issues/55411

Fixes 86bc9a732b7f ("ceph: flush the mdlog for filesystem sync")
---
  fs/ceph/mds_client.c | 12 +++++-------
  1 file changed, 5 insertions(+), 7 deletions(-)

Xiubo, feel free to fold this into the original patch so we can avoid the regression.

fs/ceph/mds_client.c +1 -7
index 2f17ca3c10b1..1e7df3b2dffd 100644
@@ -4790,18 +4790,16 @@ static void flush_mdlog_and_wait_mdsc_unsafe_requests(struct ceph_mds_client *md
  			nextreq = NULL;
  		if (req->r_op != CEPH_MDS_OP_SETFILELOCK &&
  		    (req->r_op & CEPH_MDS_OP_WRITE)) {
-			struct ceph_mds_session *s;
+			struct ceph_mds_session *s = req->r_session;
 
-			/* write op */
-			ceph_mdsc_get_request(req);
-			if (nextreq)
-				ceph_mdsc_get_request(nextreq);
-
-			s = req->r_session;
  			if (!s) {

fs/ceph/mds_client.c static void flush_mdlog_and_wait_mdsc_unsafe_requests(struct ceph_mds_client *md · line 4805

Quoted 10 lines
fs/ceph/mds_client.c +4 -0
  				req = nextreq;
  				continue;
  			}
+
+			ceph_mdsc_get_request(req);
+			if (nextreq)
+				ceph_mdsc_get_request(nextreq);
  			s = ceph_get_mds_session(s);
  			mutex_unlock(&mdsc->mutex);
 

Good catch!

Thanks Jeff, I will fold this into the original patch.

-- Xiubo