mds/events/EImportStart.h\
mds/events/EMetaBlob.h\
mds/events/EOpen.h\
- mds/events/EPurgeFinish.h\
mds/events/ESession.h\
mds/events/ESessions.h\
mds/events/ESlaveUpdate.h\
#include "events/EOpen.h"
#include "events/ECommitted.h"
-#include "events/EPurgeFinish.h"
-
#include "events/ETableClient.h"
#include "events/ETableServer.h"
case EVENT_OPEN: le = new EOpen; break;
case EVENT_COMMITTED: le = new ECommitted; break;
- case EVENT_PURGEFINISH: le = new EPurgeFinish; break;
-
case EVENT_TABLECLIENT: le = new ETableClient; break;
case EVENT_TABLESERVER: le = new ETableServer; break;
#define EVENT_OPEN 22
#define EVENT_COMMITTED 23
-#define EVENT_PURGEFINISH 30
-
#define EVENT_TABLECLIENT 42
#define EVENT_TABLESERVER 43
//xlist<CInode*> purging_inodes;
set<CInode*> truncating_inodes;
- map<CInode*, map<loff_t,loff_t> > purging_inodes;
map<int, hash_set<version_t> > pending_commit_tids; // mdstable
set<metareqid_t> uncommitted_masters;
#include "events/EUpdate.h"
#include "events/ESlaveUpdate.h"
#include "events/EString.h"
-#include "events/EPurgeFinish.h"
#include "events/EImportFinish.h"
#include "events/EFragment.h"
#include "events/ECommitted.h"
-// ----------------------------
-// purge
-
-class C_MDC_PurgeFinish : public Context {
- MDCache *mdc;
- CInode *in;
- loff_t newsize, oldsize;
-public:
- C_MDC_PurgeFinish(MDCache *c, CInode *i, loff_t ns, loff_t os) :
- mdc(c), in(i), newsize(ns), oldsize(os) {}
- void finish(int r) {
- mdc->purge_inode_finish(in, newsize, oldsize);
- }
-};
-class C_MDC_PurgeFinish2 : public Context {
- MDCache *mdc;
- CInode *in;
- loff_t newsize, oldsize;
-public:
- C_MDC_PurgeFinish2(MDCache *c, CInode *i, loff_t ns, loff_t os) :
- mdc(c), in(i), newsize(ns), oldsize(os) {}
- void finish(int r) {
- mdc->purge_inode_finish_2(in, newsize, oldsize);
- }
-};
-
-/* purge_inode in
- * will be called by on unlink or rmdir or purge
- * caller responsible for journaling a matching EUpdate
- */
-void MDCache::purge_inode(CInode *in, loff_t newsize, loff_t oldsize, LogSegment *ls)
-{
- dout(10) << "purge_inode " << oldsize << " -> " << newsize
- << " on " << *in
- << dendl;
-
- assert(oldsize >= newsize);
-
- purging[in][newsize] = oldsize;
- purging_ls[in][newsize] = ls;
- ls->purging_inodes[in][newsize] = oldsize;
-
- _do_purge_inode(in, newsize, oldsize);
-}
-
-void MDCache::_do_purge_inode(CInode *in, loff_t newsize, loff_t oldsize)
-{
- SnapContext nullsnap;
- in->get(CInode::PIN_PURGING);
-
- // remove
- if (newsize < oldsize) {
- SnapRealm *realm = in->find_snaprealm();
- const SnapContext *snapc;
- if (realm) {
- dout(10) << "_do_purge_inode realm " << *realm << dendl;
- snapc = &realm->get_snap_context();
- } else {
- dout(10) << "_do_purge_inode NO realm, using null context" << dendl;
- snapc = &nullsnap;
- assert(in->last == CEPH_NOSNAP);
- }
- dout(10) << "_do_purge_inode snapc " << snapc << " on " << *in << dendl;
- mds->filer->remove(in->inode.ino, &in->inode.layout, *snapc,
- newsize, oldsize-newsize, 0,
- 0, new C_MDC_PurgeFinish(this, in, newsize, oldsize));
- } else {
- // no need, empty file, just log it
- purge_inode_finish(in, newsize, oldsize);
- }
-}
-
-void MDCache::purge_inode_finish(CInode *in, loff_t newsize, loff_t oldsize)
-{
- dout(10) << "purge_inode_finish " << oldsize << " -> " << newsize
- << " on " << *in << dendl;
-
- // log completion
- mds->mdlog->submit_entry(new EPurgeFinish(in->ino(), newsize, oldsize),
- new C_MDC_PurgeFinish2(this, in, newsize, oldsize));
-}
-
-void MDCache::purge_inode_finish_2(CInode *in, loff_t newsize, loff_t oldsize)
-{
- dout(10) << "purge_inode_finish_2 " << oldsize << " -> " << newsize
- << " on " << *in << dendl;
-
- // remove from purging list
- LogSegment *ls = purging_ls[in][newsize];
- purging[in].erase(newsize);
- purging_ls[in].erase(newsize);
- if (purging[in].empty()) {
- purging.erase(in);
- purging_ls.erase(in);
- }
-
- assert(ls->purging_inodes.count(in));
- assert(ls->purging_inodes[in].count(newsize));
- assert(ls->purging_inodes[in][newsize] == oldsize);
- ls->purging_inodes[in].erase(newsize);
- if (ls->purging_inodes[in].empty())
- ls->purging_inodes.erase(in);
-
- in->put(CInode::PIN_PURGING);
-
- // tell anyone who cares (log flusher?)
- if (purging.count(in) == 0 ||
- purging[in].rbegin()->first < newsize) {
- list<Context*> ls;
- ls.swap(waiting_for_purge[in][newsize]);
- waiting_for_purge[in].erase(newsize);
- if (waiting_for_purge[in].empty())
- waiting_for_purge.erase(in);
- finish_contexts(ls, 0);
- }
-}
-
-void MDCache::add_recovered_purge(CInode *in, loff_t newsize, loff_t oldsize, LogSegment *ls)
-{
- assert(purging[in].count(newsize) == 0);
- purging[in][newsize] = oldsize;
- purging_ls[in][newsize] = ls;
- ls->purging_inodes[in][newsize] = oldsize;
-}
-
-void MDCache::remove_recovered_purge(CInode *in, loff_t newsize, loff_t oldsize)
-{
- purging[in].erase(newsize);
-}
-
-void MDCache::start_recovered_purges()
-{
- dout(10) << "start_recovered_purges (" << purging.size() << " purges)" << dendl;
-
- for (map<CInode*, map<loff_t, loff_t> >::iterator p = purging.begin();
- p != purging.end();
- ++p) {
- for (map<loff_t,loff_t>::iterator q = p->second.begin();
- q != p->second.end();
- ++q) {
- dout(10) << "start_recovered_purges "
- << q->second << " -> " << q->first
- << " on " << *p->first
- << dendl;
- _do_purge_inode(p->first, q->first, q->second);
- }
- }
-}
void remove_recovered_truncate(CInode *in);
void start_recovered_truncates();
- // inode purging
- void purge_inode(CInode *in, loff_t newsize, loff_t oldsize, LogSegment *ls);
- void _do_purge_inode(CInode *in, loff_t newsize, loff_t oldsize);
- void purge_inode_finish(CInode *in, loff_t newsize, loff_t oldsize);
- void purge_inode_finish_2(CInode *in, loff_t newsize, loff_t oldsize);
- bool is_purging(CInode *in, loff_t newsize, loff_t oldsize) {
- return purging.count(in) && purging[in].count(newsize);
- }
- void wait_for_purge(CInode *in, loff_t newsize, Context *c) {
- waiting_for_purge[in][newsize].push_back(c);
- }
-
- void add_recovered_purge(CInode *in, loff_t newsize, loff_t oldsize, LogSegment *ls);
- void remove_recovered_purge(CInode *in, loff_t newsize, loff_t oldsize);
- void start_recovered_purges();
-
public:
CDir *get_auth_container(CDir *in);
snapclient->finish_recovery();
mdcache->start_recovered_truncates();
- mdcache->start_recovered_purges();
mdcache->do_file_recover();
// tell connected clients
list<inodeno_t> truncate_start; // start truncate
map<inodeno_t,__u64> truncate_finish; // finished truncate (started in segment blah)
- list< triple<inodeno_t,uint64_t,uint64_t> > purging_inodes;
vector<inodeno_t> destroyed_inodes;
// idempotent op(s)
::encode(sessionmapv, bl);
::encode(truncate_start, bl);
::encode(truncate_finish, bl);
- ::encode(purging_inodes, bl);
::encode(destroyed_inodes, bl);
::encode(client_reqs, bl);
}
::decode(sessionmapv, bl);
::decode(truncate_start, bl);
::decode(truncate_finish, bl);
- ::decode(purging_inodes, bl);
::decode(destroyed_inodes, bl);
::decode(client_reqs, bl);
}
truncate_finish[ino] = segoff;
}
- void add_inode_purge(inodeno_t ino, uint64_t newsize, uint64_t oldsize) {
- purging_inodes.push_back(triple<inodeno_t,uint64_t,uint64_t>(ino, newsize, oldsize));
- }
void add_destroyed_inode(inodeno_t ino) {
destroyed_inodes.push_back(ino);
}
+++ /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 __EPURGE_H
-#define __EPURGE_H
-
-#include "config.h"
-#include "include/types.h"
-
-class EPurgeFinish : public LogEvent {
- protected:
- inodeno_t ino;
- off_t newsize, oldsize;
-
- public:
- EPurgeFinish(inodeno_t i, off_t ns, off_t os) :
- LogEvent(EVENT_PURGEFINISH),
- ino(i), newsize(ns), oldsize(os) { }
- EPurgeFinish() : LogEvent(EVENT_PURGEFINISH) { }
-
- void print(ostream& out) {
- out << "purgefinish " << ino << " " << oldsize << " ->" << newsize;
- }
-
- void encode(bufferlist &bl) const {
- ::encode(ino, bl);
- ::encode(newsize, bl);
- ::encode(oldsize, bl);
- }
- void decode(bufferlist::iterator &bl) {
- ::decode(ino, bl);
- ::decode(newsize, bl);
- ::decode(oldsize, bl);
- }
-
- void update_segment();
- void replay(MDS *mds);
-};
-
-#endif
#include "events/EOpen.h"
#include "events/ECommitted.h"
-#include "events/EPurgeFinish.h"
-
#include "events/EExport.h"
#include "events/EImportStart.h"
#include "events/EImportFinish.h"
(*p)->add_waiter(CInode::WAIT_TRUNC, gather->new_sub());
}
- // purging
- for (map<CInode*, map<loff_t,loff_t> >::iterator p = purging_inodes.begin();
- p != purging_inodes.end();
- ++p) {
- CInode *in = p->first;
- dout(10) << "try_to_expire waiting for purge of " << *in << dendl;
- if (!gather) gather = new C_Gather;
- mds->mdcache->wait_for_purge(in, p->second.begin()->first, gather->new_sub());
- }
-
// FIXME client requests...?
// audit handling of anchor transactions?
}
}
- // purging inodes
- for (list< triple<inodeno_t,uint64_t,uint64_t> >::iterator p = purging_inodes.begin();
- p != purging_inodes.end();
- ++p) {
- CInode *in = mds->mdcache->get_inode(p->first);
- assert(in);
- dout(10) << "EMetaBlob.replay will purging "
- << p->third << " -> " << p->second
- << " on " << *in << dendl;
- mds->mdcache->add_recovered_purge(in, p->second, p->third, logseg);
- }
-
// destroyed inodes
for (vector<inodeno_t>::iterator p = destroyed_inodes.begin();
p != destroyed_inodes.end();
-// -----------------------
-// EPurgeFinish
-
-
-void EPurgeFinish::update_segment()
-{
- // ** update purge lists?
-}
-
-void EPurgeFinish::replay(MDS *mds)
-{
- dout(10) << "EPurgeFinish.replay " << ino << " " << oldsize << " -> " << newsize << dendl;
- CInode *in = mds->mdcache->get_inode(ino);
-
- // if we don't have *in at this point, it's because purge_stray is lazy and
- // doesn't jouranl it's intent to purge. no worries, if *in isn't in the cache,
- // it's not in the purge table either. we'll eval_stray when we finish
- // recovery.
- //assert(in);
- if (in)
- mds->mdcache->remove_recovered_purge(in, newsize, oldsize);
-}
-
-