mirror of
https://github.com/ceph/ceph
synced 2025-01-20 10:01:45 +00:00
mon: lose ClientTicket; simplify mon's client map [disk format change]
This commit is contained in:
parent
79625540f2
commit
a74c1a99ff
@ -1,50 +0,0 @@
|
||||
// -*- 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 __CEPH_AUTH_CLIENTTICKET
|
||||
#define __CEPH_AUTH_CLIENTTICKET
|
||||
|
||||
#include "include/types.h"
|
||||
|
||||
struct ClientTicket {
|
||||
entity_addr_t addr;
|
||||
utime_t created, expires;
|
||||
string nonce;
|
||||
map<string, bufferlist> caps;
|
||||
__u32 flags;
|
||||
|
||||
void encode(bufferlist& bl) const {
|
||||
__u8 v = 1;
|
||||
::encode(v, bl);
|
||||
::encode(addr, bl);
|
||||
::encode(created, bl);
|
||||
::encode(expires, bl);
|
||||
::encode(nonce, bl);
|
||||
::encode(caps, bl);
|
||||
::encode(flags, bl);
|
||||
}
|
||||
void decode(bufferlist::iterator& bl) {
|
||||
__u8 v;
|
||||
::decode(v, bl);
|
||||
::decode(addr, bl);
|
||||
::decode(created, bl);
|
||||
::decode(expires, bl);
|
||||
::decode(nonce, bl);
|
||||
::decode(caps, bl);
|
||||
::decode(flags, bl);
|
||||
}
|
||||
};
|
||||
WRITE_CLASS_ENCODER(ClientTicket)
|
||||
|
||||
#endif
|
@ -24,22 +24,22 @@
|
||||
using namespace std;
|
||||
|
||||
#include "include/types.h"
|
||||
#include "auth/ClientTicket.h"
|
||||
|
||||
struct client_info_t {
|
||||
ClientTicket ticket;
|
||||
bufferlist signed_ticket;
|
||||
|
||||
entity_addr_t addr() { return entity_addr_t(ticket.addr); }
|
||||
utime_t created() { return utime_t(ticket.created); }
|
||||
entity_addr_t addr;
|
||||
utime_t created;
|
||||
|
||||
void encode(bufferlist& bl) const {
|
||||
::encode(ticket, bl);
|
||||
::encode(signed_ticket, bl);
|
||||
__u8 v = 1;
|
||||
::encode(v, bl);
|
||||
::encode(addr, bl);
|
||||
::encode(created, bl);
|
||||
}
|
||||
void decode(bufferlist::iterator& bl) {
|
||||
::decode(ticket, bl);
|
||||
::decode(signed_ticket, bl);
|
||||
__u8 v;
|
||||
::decode(v, bl);
|
||||
::decode(addr, bl);
|
||||
::decode(created, bl);
|
||||
}
|
||||
};
|
||||
|
||||
@ -97,7 +97,7 @@ public:
|
||||
for (map<uint32_t,client_info_t>::iterator p = client_info.begin();
|
||||
p != client_info.end();
|
||||
++p) {
|
||||
addr_client[p->second.addr()] = p->first;
|
||||
addr_client[p->second.addr] = p->first;
|
||||
}
|
||||
}
|
||||
void apply_incremental(Incremental &inc) {
|
||||
@ -108,14 +108,14 @@ public:
|
||||
p != inc.mount.end();
|
||||
++p) {
|
||||
client_info[p->first] = p->second;
|
||||
addr_client[p->second.addr()] = p->first;
|
||||
addr_client[p->second.addr] = p->first;
|
||||
}
|
||||
|
||||
for (set<int32_t>::iterator p = inc.unmount.begin();
|
||||
p != inc.unmount.end();
|
||||
++p) {
|
||||
assert(client_info.count(*p));
|
||||
addr_client.erase(client_info[*p].addr());
|
||||
addr_client.erase(client_info[*p].addr);
|
||||
client_info.erase(*p);
|
||||
}
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ bool ClientMonitor::preprocess_query(PaxosServiceMessage *m)
|
||||
_unmounted((MClientUnmount*)m);
|
||||
return true;
|
||||
}
|
||||
if (client_map.client_info[client].addr() == m->get_orig_source_addr() &&
|
||||
if (client_map.client_info[client].addr == m->get_orig_source_addr() &&
|
||||
pending_inc.unmount.count(client)) {
|
||||
dout(7) << " client" << client << " already unmounting" << dendl;
|
||||
delete m;
|
||||
@ -242,17 +242,15 @@ bool ClientMonitor::prepare_update(PaxosServiceMessage *m)
|
||||
} else {
|
||||
dout(10) << "mount: client" << client << " requested by " << addr << dendl;
|
||||
if (client_map.client_info.count(client)) {
|
||||
assert(client_map.client_info[client].addr() != addr);
|
||||
assert(client_map.client_info[client].addr != addr);
|
||||
dout(0) << "mount: WARNING: client" << client << " requested by " << addr
|
||||
<< ", which used to be " << client_map.client_info[client].addr() << dendl;
|
||||
<< ", which used to be " << client_map.client_info[client].addr << dendl;
|
||||
}
|
||||
}
|
||||
|
||||
client_info_t info;
|
||||
info.ticket.addr = addr;
|
||||
info.ticket.created = g_clock.now();
|
||||
info.ticket.expires = utime_t();
|
||||
::encode(info.ticket, info.signed_ticket);
|
||||
info.addr = addr;
|
||||
info.created = g_clock.now();
|
||||
pending_inc.add_mount(client, info);
|
||||
paxos->wait_for_commit(new C_Mounted(this, client, (MClientMount*)m));
|
||||
ss << "client" << client << " " << addr << " mounted";
|
||||
@ -269,7 +267,7 @@ bool ClientMonitor::prepare_update(PaxosServiceMessage *m)
|
||||
|
||||
pending_inc.add_unmount(client);
|
||||
paxos->wait_for_commit(new C_Unmounted(this, (MClientUnmount*)m));
|
||||
ss << "client" << client << " " << client_map.client_info[client].addr() << " unmounted";
|
||||
ss << "client" << client << " " << client_map.client_info[client].addr << " unmounted";
|
||||
mon->get_logclient()->log(LOG_INFO, ss);
|
||||
}
|
||||
return true;
|
||||
@ -312,8 +310,8 @@ bool ClientMonitor::preprocess_command(MMonCommand *m)
|
||||
p != client_map.client_info.end();
|
||||
p++) {
|
||||
ss << "client" << p->first
|
||||
<< "\t" << p->second.addr()
|
||||
<< "\t" << p->second.created()
|
||||
<< "\t" << p->second.addr
|
||||
<< "\t" << p->second.created
|
||||
<< std::endl;
|
||||
}
|
||||
while (!ss.eof()) {
|
||||
@ -366,7 +364,6 @@ void ClientMonitor::_mounted(int client, MClientMount *m)
|
||||
// reply with client ticket
|
||||
MClientMountAck *ack = new MClientMountAck;
|
||||
mon->monmap->encode(ack->monmap_bl);
|
||||
ack->signed_ticket = client_map.client_info[client].signed_ticket;
|
||||
|
||||
mon->messenger->send_message(ack, to);
|
||||
|
||||
|
@ -255,8 +255,6 @@ void MonClient::handle_mount_ack(MClientMountAck* m)
|
||||
|
||||
// ticket
|
||||
signed_ticket = m->signed_ticket;
|
||||
p = signed_ticket.begin();
|
||||
::decode(ticket, p);
|
||||
|
||||
messenger->reset_myname(m->get_dest());
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "msg/Messenger.h"
|
||||
|
||||
#include "MonMap.h"
|
||||
#include "auth/ClientTicket.h"
|
||||
|
||||
#include "common/Timer.h"
|
||||
|
||||
@ -34,7 +33,6 @@ public:
|
||||
private:
|
||||
Messenger *messenger;
|
||||
|
||||
ClientTicket ticket;
|
||||
bufferlist signed_ticket;
|
||||
|
||||
Context *mount_timeout_event;
|
||||
@ -111,7 +109,6 @@ private:
|
||||
void set_messenger(Messenger *m) { messenger = m; }
|
||||
|
||||
bufferlist& get_signed_ticket() { return signed_ticket; }
|
||||
ClientTicket& get_ticket() { return ticket; }
|
||||
|
||||
};
|
||||
|
||||
|
@ -35,6 +35,6 @@ inline const char *get_paxos_name(int p) {
|
||||
}
|
||||
}
|
||||
|
||||
#define CEPH_MON_ONDISK_MAGIC "ceph mon volume v009"
|
||||
#define CEPH_MON_ONDISK_MAGIC "ceph mon volume v010"
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user