Skip to contentSkip to conversation

ceph: remove req from unsafe list before calling __unregister_request

PATCH In review Jeff Layton 2 participants 3 messages Feb 9, 2017 – Feb 15, 2017 Ceph client

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: remove req from unsafe list before calling __unregister_request

...and while we're at it, let's ensure that no one inadvertantly leaves this thing on the unsafe list. There's no reason it should ever be on a s_unsafe list but not in the request tree.

---
 fs/ceph/mds_client.c | 3 +++
 1 file changed, 3 insertions(+)
fs/ceph/mds_client.c +3 -0
index 52521f339745..b47e97680a66 100644
@@ -628,6 +628,8 @@ static void __unregister_request(struct ceph_mds_client *mdsc,
 {
 	dout("__unregister_request %p tid %lld\n", req, req->r_tid);
 
+	WARN_ON_ONCE(!list_empty(&req->r_unsafe_item));
+
 	if (req->r_tid == mdsc->oldest_tid) {
 		struct rb_node *p = rb_next(&req->r_node);
 		mdsc->oldest_tid = 0;
@@ -3512,6 +3514,7 @@ static void wait_requests(struct ceph_mds_client *mdsc)
 		while ((req = __get_oldest_req(mdsc))) {
 			dout("wait_requests timed out on tid %llu\n",
 			     req->r_tid);
+			list_del_init(&req->r_unsafe_item);
 			__unregister_request(mdsc, req);
 		}
 	}
Signature · 1 line
2.9.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 28 lines · Jeff Layton

...and while we're at it, let's ensure that no one inadvertantly leaves this thing on the unsafe list. There's no reason it should ever be on a s_unsafe list but not in the request tree.

---
fs/ceph/mds_client.c | 3 +++

1 file changed, 3 insertions(+)
fs/ceph/mds_client.c +2 -0
index 52521f339745..b47e97680a66 100644
@@ -628,6 +628,8 @@ static void __unregister_request(struct ceph_mds_client *mdsc,
 {
 	dout("__unregister_request %p tid %lld\n", req, req->r_tid);
 
+	WARN_ON_ONCE(!list_empty(&req->r_unsafe_item));
+
 	if (req->r_tid == mdsc->oldest_tid) {
 		struct rb_node *p = rb_next(&req->r_node);
 		mdsc->oldest_tid = 0;

fs/ceph/mds_client.c static void wait_requests(struct ceph_mds_client *mdsc) · line 3520

Quoted 7 lines
fs/ceph/mds_client.c +1 -0
@@ -3512,6 +3514,7 @@ static void wait_requests(struct ceph_mds_client *mdsc)
 		while ((req = __get_oldest_req(mdsc))) {
 			dout("wait_requests timed out on tid %llu\n",
 			     req->r_tid);
+			list_del_init(&req->r_unsafe_item);
 			__unregister_request(mdsc, req);
 		}
 	}
Quoted 3 lines
Signature · 1 line
2.9.3
#2 lore raw
In reply to Jeff Layton
Quoted 25 lines · Jeff Layton

...and while we're at it, let's ensure that no one inadvertantly leaves this thing on the unsafe list. There's no reason it should ever be on a s_unsafe list but not in the request tree.

---
 fs/ceph/mds_client.c | 3 +++
 1 file changed, 3 insertions(+)
fs/ceph/mds_client.c +2 -0
index 52521f339745..b47e97680a66 100644
@@ -628,6 +628,8 @@ static void __unregister_request(struct ceph_mds_client *mdsc,
 {
 	dout("__unregister_request %p tid %lld\n", req, req->r_tid);
 
+	WARN_ON_ONCE(!list_empty(&req->r_unsafe_item));
+
 	if (req->r_tid == mdsc->oldest_tid) {
 		struct rb_node *p = rb_next(&req->r_node);
 		mdsc->oldest_tid = 0;

fs/ceph/mds_client.c static void wait_requests(struct ceph_mds_client *mdsc) · line 3520

Quoted 7 lines
fs/ceph/mds_client.c +1 -0
@@ -3512,6 +3514,7 @@ static void wait_requests(struct ceph_mds_client *mdsc)
 		while ((req = __get_oldest_req(mdsc))) {
 			dout("wait_requests timed out on tid %llu\n",
 			     req->r_tid);
+			list_del_init(&req->r_unsafe_item);
 			__unregister_request(mdsc, req);
 		}
 	}

After going over the kernel code more thoroughly, I started to get concerned that there were some cases (particularly those involving fatal signals) where we could end up leaving it on the list before calling __unregister_request.

I've just sent a v2 patch, that moves the list_del_init into __unregister_request itself, which ensures that it's always removed from the list in those cases as well.

Signature · 1 line
Jeff Layton <[email protected]>