aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph/osd_client.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ceph/osd_client.c')
-rw-r--r--fs/ceph/osd_client.c63
1 files changed, 60 insertions, 3 deletions
diff --git a/fs/ceph/osd_client.c b/fs/ceph/osd_client.c
index 0a16c4f951f9..ca0ee68c322a 100644
--- a/fs/ceph/osd_client.c
+++ b/fs/ceph/osd_client.c
@@ -11,6 +11,7 @@
11#include "osd_client.h" 11#include "osd_client.h"
12#include "messenger.h" 12#include "messenger.h"
13#include "decode.h" 13#include "decode.h"
14#include "auth.h"
14 15
15const static struct ceph_connection_operations osd_con_ops; 16const static struct ceph_connection_operations osd_con_ops;
16 17
@@ -331,6 +332,7 @@ static struct ceph_osd *create_osd(struct ceph_osd_client *osdc)
331 osd->o_con.private = osd; 332 osd->o_con.private = osd;
332 osd->o_con.ops = &osd_con_ops; 333 osd->o_con.ops = &osd_con_ops;
333 osd->o_con.peer_name.type = CEPH_ENTITY_TYPE_OSD; 334 osd->o_con.peer_name.type = CEPH_ENTITY_TYPE_OSD;
335
334 return osd; 336 return osd;
335} 337}
336 338
@@ -880,9 +882,15 @@ void ceph_osdc_handle_map(struct ceph_osd_client *osdc, struct ceph_msg *msg)
880 /* verify fsid */ 882 /* verify fsid */
881 ceph_decode_need(&p, end, sizeof(fsid), bad); 883 ceph_decode_need(&p, end, sizeof(fsid), bad);
882 ceph_decode_copy(&p, &fsid, sizeof(fsid)); 884 ceph_decode_copy(&p, &fsid, sizeof(fsid));
883 if (ceph_fsid_compare(&fsid, &osdc->client->monc.monmap->fsid)) { 885 if (osdc->client->monc.have_fsid) {
884 pr_err("got osdmap with wrong fsid, ignoring\n"); 886 if (ceph_fsid_compare(&fsid,
885 return; 887 &osdc->client->monc.monmap->fsid)) {
888 pr_err("got osdmap with wrong fsid, ignoring\n");
889 return;
890 }
891 } else {
892 ceph_fsid_set(&osdc->client->monc.monmap->fsid, &fsid);
893 osdc->client->monc.have_fsid = true;
886 } 894 }
887 895
888 down_write(&osdc->map_sem); 896 down_write(&osdc->map_sem);
@@ -1302,10 +1310,59 @@ static void put_osd_con(struct ceph_connection *con)
1302 put_osd(osd); 1310 put_osd(osd);
1303} 1311}
1304 1312
1313/*
1314 * authentication
1315 */
1316static int get_authorizer(struct ceph_connection *con,
1317 void **buf, int *len, int *proto,
1318 void **reply_buf, int *reply_len, int force_new)
1319{
1320 struct ceph_osd *o = con->private;
1321 struct ceph_osd_client *osdc = o->o_osdc;
1322 struct ceph_auth_client *ac = osdc->client->monc.auth;
1323 int ret = 0;
1324
1325 if (force_new && o->o_authorizer) {
1326 ac->ops->destroy_authorizer(ac, o->o_authorizer);
1327 o->o_authorizer = NULL;
1328 }
1329 if (o->o_authorizer == NULL) {
1330 ret = ac->ops->create_authorizer(
1331 ac, CEPH_ENTITY_TYPE_OSD,
1332 &o->o_authorizer,
1333 &o->o_authorizer_buf,
1334 &o->o_authorizer_buf_len,
1335 &o->o_authorizer_reply_buf,
1336 &o->o_authorizer_reply_buf_len);
1337 if (ret)
1338 return ret;
1339 }
1340
1341 *proto = ac->protocol;
1342 *buf = o->o_authorizer_buf;
1343 *len = o->o_authorizer_buf_len;
1344 *reply_buf = o->o_authorizer_reply_buf;
1345 *reply_len = o->o_authorizer_reply_buf_len;
1346 return 0;
1347}
1348
1349
1350static int verify_authorizer_reply(struct ceph_connection *con, int len)
1351{
1352 struct ceph_osd *o = con->private;
1353 struct ceph_osd_client *osdc = o->o_osdc;
1354 struct ceph_auth_client *ac = osdc->client->monc.auth;
1355
1356 return ac->ops->verify_authorizer_reply(ac, o->o_authorizer, len);
1357}
1358
1359
1305const static struct ceph_connection_operations osd_con_ops = { 1360const static struct ceph_connection_operations osd_con_ops = {
1306 .get = get_osd_con, 1361 .get = get_osd_con,
1307 .put = put_osd_con, 1362 .put = put_osd_con,
1308 .dispatch = dispatch, 1363 .dispatch = dispatch,
1364 .get_authorizer = get_authorizer,
1365 .verify_authorizer_reply = verify_authorizer_reply,
1309 .alloc_msg = alloc_msg, 1366 .alloc_msg = alloc_msg,
1310 .fault = osd_reset, 1367 .fault = osd_reset,
1311 .alloc_middle = ceph_alloc_middle, 1368 .alloc_middle = ceph_alloc_middle,