libceph: use RB_EMPTY_NODE() in the osd client
cover libceph: use RB_EMPTY_NODE() in the osd client
The first one of these is an update based on a previous post. The other two are new, but basically address the same issue in two other spots in the osd client code.
-Alex
[PATCH 1/3] libceph: init osd->o_node in create_osd() [PATCH 2/3] libceph: init event->node in ceph_osdc_create_event() [PATCH 3/3] libceph: don't use rb_init_node() in
PATCH v2 1/3 libceph: init osd->o_node in create_osd()
The red-black node node in the ceph osd structure is not initialized in create_osd(). Because this node can be the subject of a RB_EMPTY_NODE() call later on, we should ensure the node is initialized properly for that. Add a call to RB_CLEAR_NODE() initialize it.
---
v2: use RB_CLEAR_NODE() instead of rb_init_node()
net/ceph/osd_client.c | 1 + 1 file changed, 1 insertion(+)
net/ceph/osd_client.c +0 -0
@@ -642,6 +642,7 @@ static struct ceph_osd *create_osd(struct
ceph_osd_client *osdc, int onum)
atomic_set(&osd->o_ref, 1);
osd->o_osdc = osdc;
osd->o_osd = onum;
+ RB_CLEAR_NODE(&osd->o_node);
INIT_LIST_HEAD(&osd->o_requests);
INIT_LIST_HEAD(&osd->o_linger_requests);
INIT_LIST_HEAD(&osd->o_osd_lru);
Signature · 1 line
1.7.9.5
PATCH 2/3 libceph: init event->node in ceph_osdc_create_event()
In reply to Alex ElderThe red-black node node in the ceph osd event structure is not initialized in create_osdc_create_event(). Because this node can be the subject of a RB_EMPTY_NODE() call later on, we should ensure the node is initialized properly for that.
--- net/ceph/osd_client.c | 1 + 1 file changed, 1 insertion(+)
net/ceph/osd_client.c +0 -0
@@ -1563,6 +1563,7 @@ int ceph_osdc_create_event(struct ceph_osd_client
*osdc,
event->data = data;
event->osdc = osdc;
INIT_LIST_HEAD(&event->osd_node);
+ RB_CLEAR_NODE(&event->node);
kref_init(&event->kref); /* one ref for us */
kref_get(&event->kref); /* one ref for the caller */
init_completion(&event->completion);
Signature · 1 line
1.7.9.5
PATCH 3/3 libceph: don't use rb_init_node() in ceph_osdc_alloc_request()
In reply to Alex ElderThe red-black node in the ceph osd request structure is initialized in ceph_osdc_alloc_request() using rbd_init_node(). We do need to initialize this, because in __unregister_request() we call RB_EMPTY_NODE(), which expects the node it's checking to have been initialized. But rb_init_node() is apparently overkill, and may in fact be on its way out. So use RB_CLEAR_NODE() instead.
For a little more background, see this commit:
4c199a93 rbtree: empty nodes have no color"
--- net/ceph/osd_client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ceph/osd_client.c +0 -0
@@ -221,7 +221,7 @@ struct ceph_osd_request
*ceph_osdc_alloc_request(struct ceph_osd_client *osdc,
kref_init(&req->r_kref); init_completion(&req->r_completion); init_completion(&req->r_safe_completion);
- rb_init_node(&req->r_node);
+ RB_CLEAR_NODE(&req->r_node);
INIT_LIST_HEAD(&req->r_unsafe_item); INIT_LIST_HEAD(&req->r_linger_item); INIT_LIST_HEAD(&req->r_linger_osd);
Signature · 1 line
1.7.9.5