aboutsummaryrefslogtreecommitdiffstats
path: root/net/ceph/osd_client.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ceph/osd_client.c')
-rw-r--r--net/ceph/osd_client.c63
1 files changed, 34 insertions, 29 deletions
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 1b0ef3c4d393..1ffebed5ce0f 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -278,7 +278,7 @@ static void osd_req_encode_op(struct ceph_osd_request *req,
278{ 278{
279 dst->op = cpu_to_le16(src->op); 279 dst->op = cpu_to_le16(src->op);
280 280
281 switch (dst->op) { 281 switch (src->op) {
282 case CEPH_OSD_OP_READ: 282 case CEPH_OSD_OP_READ:
283 case CEPH_OSD_OP_WRITE: 283 case CEPH_OSD_OP_WRITE:
284 dst->extent.offset = 284 dst->extent.offset =
@@ -664,11 +664,11 @@ static void put_osd(struct ceph_osd *osd)
664{ 664{
665 dout("put_osd %p %d -> %d\n", osd, atomic_read(&osd->o_ref), 665 dout("put_osd %p %d -> %d\n", osd, atomic_read(&osd->o_ref),
666 atomic_read(&osd->o_ref) - 1); 666 atomic_read(&osd->o_ref) - 1);
667 if (atomic_dec_and_test(&osd->o_ref)) { 667 if (atomic_dec_and_test(&osd->o_ref) && osd->o_auth.authorizer) {
668 struct ceph_auth_client *ac = osd->o_osdc->client->monc.auth; 668 struct ceph_auth_client *ac = osd->o_osdc->client->monc.auth;
669 669
670 if (osd->o_authorizer) 670 if (ac->ops && ac->ops->destroy_authorizer)
671 ac->ops->destroy_authorizer(ac, osd->o_authorizer); 671 ac->ops->destroy_authorizer(ac, osd->o_auth.authorizer);
672 kfree(osd); 672 kfree(osd);
673 } 673 }
674} 674}
@@ -841,6 +841,12 @@ static void register_request(struct ceph_osd_client *osdc,
841static void __unregister_request(struct ceph_osd_client *osdc, 841static void __unregister_request(struct ceph_osd_client *osdc,
842 struct ceph_osd_request *req) 842 struct ceph_osd_request *req)
843{ 843{
844 if (RB_EMPTY_NODE(&req->r_node)) {
845 dout("__unregister_request %p tid %lld not registered\n",
846 req, req->r_tid);
847 return;
848 }
849
844 dout("__unregister_request %p tid %lld\n", req, req->r_tid); 850 dout("__unregister_request %p tid %lld\n", req, req->r_tid);
845 rb_erase(&req->r_node, &osdc->requests); 851 rb_erase(&req->r_node, &osdc->requests);
846 osdc->num_requests--; 852 osdc->num_requests--;
@@ -2108,37 +2114,32 @@ static void put_osd_con(struct ceph_connection *con)
2108/* 2114/*
2109 * authentication 2115 * authentication
2110 */ 2116 */
2111static int get_authorizer(struct ceph_connection *con, 2117/*
2112 void **buf, int *len, int *proto, 2118 * Note: returned pointer is the address of a structure that's
2113 void **reply_buf, int *reply_len, int force_new) 2119 * managed separately. Caller must *not* attempt to free it.
2120 */
2121static struct ceph_auth_handshake *get_authorizer(struct ceph_connection *con,
2122 int *proto, int force_new)
2114{ 2123{
2115 struct ceph_osd *o = con->private; 2124 struct ceph_osd *o = con->private;
2116 struct ceph_osd_client *osdc = o->o_osdc; 2125 struct ceph_osd_client *osdc = o->o_osdc;
2117 struct ceph_auth_client *ac = osdc->client->monc.auth; 2126 struct ceph_auth_client *ac = osdc->client->monc.auth;
2118 int ret = 0; 2127 struct ceph_auth_handshake *auth = &o->o_auth;
2119 2128
2120 if (force_new && o->o_authorizer) { 2129 if (force_new && auth->authorizer) {
2121 ac->ops->destroy_authorizer(ac, o->o_authorizer); 2130 if (ac->ops && ac->ops->destroy_authorizer)
2122 o->o_authorizer = NULL; 2131 ac->ops->destroy_authorizer(ac, auth->authorizer);
2123 } 2132 auth->authorizer = NULL;
2124 if (o->o_authorizer == NULL) { 2133 }
2125 ret = ac->ops->create_authorizer( 2134 if (!auth->authorizer && ac->ops && ac->ops->create_authorizer) {
2126 ac, CEPH_ENTITY_TYPE_OSD, 2135 int ret = ac->ops->create_authorizer(ac, CEPH_ENTITY_TYPE_OSD,
2127 &o->o_authorizer, 2136 auth);
2128 &o->o_authorizer_buf,
2129 &o->o_authorizer_buf_len,
2130 &o->o_authorizer_reply_buf,
2131 &o->o_authorizer_reply_buf_len);
2132 if (ret) 2137 if (ret)
2133 return ret; 2138 return ERR_PTR(ret);
2134 } 2139 }
2135
2136 *proto = ac->protocol; 2140 *proto = ac->protocol;
2137 *buf = o->o_authorizer_buf; 2141
2138 *len = o->o_authorizer_buf_len; 2142 return auth;
2139 *reply_buf = o->o_authorizer_reply_buf;
2140 *reply_len = o->o_authorizer_reply_buf_len;
2141 return 0;
2142} 2143}
2143 2144
2144 2145
@@ -2148,7 +2149,11 @@ static int verify_authorizer_reply(struct ceph_connection *con, int len)
2148 struct ceph_osd_client *osdc = o->o_osdc; 2149 struct ceph_osd_client *osdc = o->o_osdc;
2149 struct ceph_auth_client *ac = osdc->client->monc.auth; 2150 struct ceph_auth_client *ac = osdc->client->monc.auth;
2150 2151
2151 return ac->ops->verify_authorizer_reply(ac, o->o_authorizer, len); 2152 /*
2153 * XXX If ac->ops or ac->ops->verify_authorizer_reply is null,
2154 * XXX which do we do: succeed or fail?
2155 */
2156 return ac->ops->verify_authorizer_reply(ac, o->o_auth.authorizer, len);
2152} 2157}
2153 2158
2154static int invalidate_authorizer(struct ceph_connection *con) 2159static int invalidate_authorizer(struct ceph_connection *con)
@@ -2157,7 +2162,7 @@ static int invalidate_authorizer(struct ceph_connection *con)
2157 struct ceph_osd_client *osdc = o->o_osdc; 2162 struct ceph_osd_client *osdc = o->o_osdc;
2158 struct ceph_auth_client *ac = osdc->client->monc.auth; 2163 struct ceph_auth_client *ac = osdc->client->monc.auth;
2159 2164
2160 if (ac->ops->invalidate_authorizer) 2165 if (ac->ops && ac->ops->invalidate_authorizer)
2161 ac->ops->invalidate_authorizer(ac, CEPH_ENTITY_TYPE_OSD); 2166 ac->ops->invalidate_authorizer(ac, CEPH_ENTITY_TYPE_OSD);
2162 2167
2163 return ceph_monc_validate_auth(&osdc->client->monc); 2168 return ceph_monc_validate_auth(&osdc->client->monc);