mds/mds_table_types.h\
mds/mdstypes.h\
mds/snap.h\
- messages/MCacheExpire.h\
+ messages/MAuth.h\
+ messages/MAuthReply.h\
messages/MClass.h\
messages/MClassAck.h\
messages/MClientCaps.h\
#define CEPH_MSG_CLIENT_UNMOUNT 12
#define CEPH_MSG_STATFS 13
#define CEPH_MSG_STATFS_REPLY 14
-#define CEPH_MSG_CLIENT_AUTH 15
-#define CEPH_MSG_CLIENT_AUTH_REPLY 16
+#define CEPH_MSG_AUTH 15
+#define CEPH_MSG_AUTH_REPLY 16
/* client <-> mds */
#define CEPH_MSG_MDS_GETMAP 20
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation. See file COPYING.
+ *
+ */
+
+#ifndef __MAUTH_H
+#define __MAUTH_H
+
+#include "messages/PaxosServiceMessage.h"
+
+class MAuth : public PaxosServiceMessage {
+ bufferlist auth_payload;
+public:
+ MAuth() : PaxosServiceMessage(CEPH_MSG_AUTH, 0) { }
+
+ const char *get_type_name() { return "client_auth"; }
+
+ void decode_payload() {
+ bufferlist::iterator p = payload.begin();
+ paxos_decode(p);
+ p.copy(payload.length() - p.get_off(), auth_payload);
+ }
+ void encode_payload() {
+ paxos_encode();
+ payload.append(auth_payload);
+ }
+ bufferlist& get_auth_payload() { return auth_payload; }
+};
+
+#endif
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation. See file COPYING.
+ *
+ */
+
+#ifndef __MAUTHREPLY_H
+#define __MAUTHREPLY_H
+
+#include "msg/Message.h"
+
+struct MAuthReply : public Message {
+ __s32 result;
+ cstring result_msg;
+ bufferlist result_bl;
+
+ MAuthReply(bufferlist *bl = NULL, int r = 0, const char *msg = 0) :
+ Message(CEPH_MSG_AUTH_REPLY),
+ result(r),
+ result_msg(msg) {
+ if (bl) {
+ bufferlist::iterator iter = bl->begin();
+ iter.copy(bl->length(), result_bl);
+ }
+ }
+
+ const char *get_type_name() { return "auth_reply"; }
+ void print(ostream& o) {
+ o << "auth_reply(" << result;
+ if (result_msg.length()) o << " " << result_msg;
+ o << ")";
+ }
+
+ void decode_payload() {
+ bufferlist::iterator p = payload.begin();
+ ::decode(result, p);
+ ::decode(result_bl, p);
+ ::decode(result_msg, p);
+ }
+ void encode_payload() {
+ ::encode(result, payload);
+ ::encode(result_bl, payload);
+ ::encode(result_msg, payload);
+
+ dout(0) << "MAuthReply size=" << payload.length() << dendl;
+ }
+};
+
+#endif
+++ /dev/null
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-/*
- * Ceph - scalable distributed file system
- *
- * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software
- * Foundation. See file COPYING.
- *
- */
-
-#ifndef __MCLIENTAUTH_H
-#define __MCLIENTAUTH_H
-
-#include "messages/PaxosServiceMessage.h"
-
-class MClientAuth : public PaxosServiceMessage {
- bufferlist auth_payload;
-public:
- MClientAuth() : PaxosServiceMessage(CEPH_MSG_CLIENT_AUTH, 0) { }
-
- const char *get_type_name() { return "client_auth"; }
-
- void decode_payload() {
- bufferlist::iterator p = payload.begin();
- paxos_decode(p);
- p.copy(payload.length() - p.get_off(), auth_payload);
- }
- void encode_payload() {
- paxos_encode();
- payload.append(auth_payload);
- }
- bufferlist& get_auth_payload() { return auth_payload; }
-};
-
-#endif
+++ /dev/null
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-/*
- * Ceph - scalable distributed file system
- *
- * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software
- * Foundation. See file COPYING.
- *
- */
-
-#ifndef __MCLIENTAUTHREPLY_H
-#define __MCLIENTAUTHREPLY_H
-
-#include "msg/Message.h"
-
-struct MClientAuthReply : public Message {
- __s32 result;
- cstring result_msg;
- bufferlist result_bl;
-
- MClientAuthReply(bufferlist *bl = NULL, int r = 0, const char *msg = 0) :
- Message(CEPH_MSG_CLIENT_AUTH_REPLY),
- result(r),
- result_msg(msg) {
- if (bl) {
- bufferlist::iterator iter = bl->begin();
- iter.copy(bl->length(), result_bl);
- }
- }
-
- const char *get_type_name() { return "client_auth_reply"; }
- void print(ostream& o) {
- o << "client_auth_reply(" << result;
- if (result_msg.length()) o << " " << result_msg;
- o << ")";
- }
-
- void decode_payload() {
- bufferlist::iterator p = payload.begin();
- ::decode(result, p);
- ::decode(result_bl, p);
- ::decode(result_msg, p);
- }
- void encode_payload() {
- ::encode(result, payload);
- ::encode(result_bl, payload);
- ::encode(result_msg, payload);
-
- dout(0) << "MClientAuthReply size=" << payload.length() << dendl;
- }
-};
-
-#endif
#include "MonitorStore.h"
#include "messages/MMonMap.h"
-#include "messages/MClientAuth.h"
-#include "messages/MClientAuthReply.h"
+#include "messages/MAuth.h"
+#include "messages/MAuthReply.h"
#include "messages/MClientMount.h"
#include "messages/MClientMountAck.h"
#include "messages/MClientUnmount.h"
return false;
}
-bool ClientMonitor::check_auth(MClientAuth *m)
+bool ClientMonitor::check_auth(MAuth *m)
{
stringstream ss;
// already mounted?
bufferlist response_bl;
int ret = handler->handle_request(m->get_auth_payload(), response_bl);
- MClientAuthReply *reply = new MClientAuthReply(&response_bl, ret);
+ MAuthReply *reply = new MAuthReply(&response_bl, ret);
if (reply) {
mon->messenger->send_message(reply,
dout(10) << "preprocess_query " << *m << " from " << m->get_orig_source_inst() << dendl;
switch (m->get_type()) {
- case CEPH_MSG_CLIENT_AUTH:
+ case CEPH_MSG_AUTH:
dout(0) << "YY preprocess_query" << dendl;
- return check_auth((MClientAuth *)m);
+ return check_auth((MAuth *)m);
case CEPH_MSG_CLIENT_MOUNT:
return check_mount((MClientMount *)m);
class Monitor;
class Paxos;
-class MClientAuth;
+class MAuth;
class MClientMount;
class MClientUnmount;
class MMonCommand;
void committed();
- bool check_auth(MClientAuth *m);
+ bool check_auth(MAuth *m);
bool check_mount(MClientMount *m);
void _mounted(int c, MClientMount *m);
void _unmounted(MClientUnmount *m);
#include "messages/MMonGetMap.h"
#include "messages/MMonMap.h"
#include "messages/MClientMount.h"
+#include "messages/MAuth.h"
+#include "messages/MAuthReply.h"
#include "include/nstring.h"
#include "MonClient.h"
#include "MonMap.h"
+#include "auth/Auth.h"
+
#include "config.h"
messenger->mark_down(monmap.get_inst(oldmon).addr);
monmap.pick_mon(true);
}
+
+void MonClient::_try_do_op(MonClientOpCtx& ctx, double timeout)
+{
+ dout(10) << "_try_do_op" << dendl;
+ int mon = monmap.pick_mon();
+ dout(2) << "sending client_mount to mon" << mon << dendl;
+
+ MAuth *msg = new MAuth;
+ if (!msg)
+ return;
+
+ bufferlist& bl = msg->get_auth_payload();
+
+ EntityName name;
+ entity_addr_t my_addr;
+
+ build_authenticate_request(name, my_addr, bl);
+
+ messenger->set_dispatcher(this);
+ messenger->send_message(msg, monmap.get_inst(mon));
+
+ // schedule timeout?
+ assert(ctx.timeout_event == 0);
+ ctx.timeout_event = new C_OpTimeout(this, &ctx, timeout);
+ timer.add_event_after(timeout, ctx.timeout_event);
+}
+
+/*
+ get ticket-granting-ticket for this principle
+*/
+int MonClient::do_op(MonClientOpCtx& ctx, double timeout)
+{
+ Mutex::Locker lock(monc_lock);
+
+ if (ctx.done) {
+ dout(5) << "op already done" << dendl;;
+ return 0;
+ }
+
+ // only the first does the work
+ bool itsme = false;
+ if (!ctx.num_waiters) {
+ itsme = true;
+ _try_do_op(ctx, timeout);
+ } else {
+ dout(5) << "additional get_tgt" << dendl;
+ }
+ ctx.num_waiters++;
+
+ while (!ctx.got_data ||
+ (!itsme && !ctx.done)) // non-doers wait a little longer
+ ctx.cond.Wait(monc_lock);
+
+ if (!itsme) {
+ dout(5) << "additional get_tgt returning" << dendl;
+ assert(ctx.got_data);
+ return 0;
+ }
+
+ // finish.
+ timer.cancel_event(ctx.timeout_event);
+ ctx.timeout_event = 0;
+
+ ctx.got_data = true;
+ ctx.cond.SignalAll(); // wake up non-doers
+
+ return 0;
+}
+
+void MonClient::_op_timeout(MonClientOpCtx& ctx, double timeout)
+{
+ dout(10) << "_op_timeout" << dendl;
+ ctx.timeout_event = 0;
+ _try_do_op(ctx, timeout);
+}
+
bufferlist signed_ticket;
+ bufferlist tgt;
+
Context *mount_timeout_event;
Mutex monc_lock;
bool unmounting;
Cond mount_cond, map_cond;
-
bool dispatch_impl(Message *m);
void handle_monmap(MMonMap *m);
}
};
+ class MonClientOpCtx {
+ public:
+ bool done;
+ int num_waiters;
+ Cond cond;
+ Context *timeout_event;
+ bool got_data;
+
+ MonClientOpCtx() {
+ done = false;
+ num_waiters = 0;
+ got_data = false;
+ }
+ };
+
+ class C_OpTimeout : public Context {
+ MonClient *client;
+ MonClientOpCtx *op_ctx;
+ double timeout;
+ public:
+ C_OpTimeout(MonClient *c, MonClientOpCtx *opc, double to) :
+ client(c), op_ctx(opc), timeout(to) {
+ }
+ void finish(int r) {
+ if (r >= 0) client->_op_timeout(*op_ctx, timeout);
+ }
+ };
+
void _try_mount(double timeout);
void _mount_timeout(double timeout);
void handle_mount_ack(MClientMountAck* m);
void handle_unmount(Message* m);
+ void _op_timeout(MonClientOpCtx& ctx, double timeout);
+
+ void _try_do_op(MonClientOpCtx& ctx, double timeout);
+ int do_op(MonClientOpCtx& ctx, double timeout);
+
public:
MonClient() : messenger(NULL),
monc_lock("MonClient::monc_lock"),
break;
// clients
- case CEPH_MSG_CLIENT_AUTH:
+ case CEPH_MSG_AUTH:
dout(0) << "Monitor::dispatch_impl() got CEPH_MSG_CLIENT_AUTH" << dendl;
case CEPH_MSG_CLIENT_MOUNT:
case CEPH_MSG_CLIENT_UNMOUNT:
#include "messages/MMonMap.h"
#include "messages/MMonGetMap.h"
-#include "messages/MClientAuth.h"
-#include "messages/MClientAuthReply.h"
+#include "messages/MAuth.h"
+#include "messages/MAuthReply.h"
#include "messages/MClientMount.h"
#include "messages/MClientMountAck.h"
#include "messages/MClientUnmount.h"
m = new MRemoveSnaps;
break;
-
- // clients
- case CEPH_MSG_CLIENT_AUTH:
- m = new MClientAuth;
+ // auth
+ case CEPH_MSG_AUTH:
+ m = new MAuth;
break;
- case CEPH_MSG_CLIENT_AUTH_REPLY:
- m = new MClientAuthReply;
+ case CEPH_MSG_AUTH_REPLY:
+ m = new MAuthReply;
break;
+
+ // clients
case CEPH_MSG_CLIENT_MOUNT:
m = new MClientMount;
break;