diff mbox series

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

Message ID 20220422172911.94861-1-jlayton@kernel.org (mailing list archive)
State New, archived
Headers show
Series ceph: fix request refcount leak when session can't be acquired | expand

Commit Message

Jeff Layton April 22, 2022, 5:29 p.m. UTC
...in flush_mdlog_and_wait_mdsc_unsafe_requests.

URL: https://tracker.ceph.com/issues/55411
Fixes: 86bc9a732b7f ("ceph: flush the mdlog for filesystem sync")
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 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.

Comments

Xiubo Li April 24, 2022, 12:16 a.m. UTC | #1
On 4/23/22 1:29 AM, Jeff Layton wrote:
> ...in flush_mdlog_and_wait_mdsc_unsafe_requests.
>
> URL: https://tracker.ceph.com/issues/55411
> Fixes: 86bc9a732b7f ("ceph: flush the mdlog for filesystem sync")
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>   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.
>
> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
> index 2f17ca3c10b1..1e7df3b2dffd 100644
> --- a/fs/ceph/mds_client.c
> +++ b/fs/ceph/mds_client.c
> @@ -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);
>   

Good catch!

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

-- Xiubo
diff mbox series

Patch

diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 2f17ca3c10b1..1e7df3b2dffd 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -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);