#include <set>
#include <string_view>
+#include "CInode.h"
+#include "SimpleLock.h"
+#include "MDSContext.h"
+#include "Mutation.h"
+#include "messages/MClientReply.h"
+
+struct SnapRealm;
+
class MDSRank;
class Session;
class CDentry;
-struct SnapRealm;
-
class Capability;
-
class SimpleLock;
class ScatterLock;
class LocalLock;
-#include "CInode.h"
-#include "SimpleLock.h"
-#include "MDSContext.h"
-#include "Mutation.h"
-#include "messages/MClientReply.h"
-
class Locker {
-private:
- MDSRank *mds;
- MDCache *mdcache;
-
- public:
+public:
Locker(MDSRank *m, MDCache *c);
SimpleLock *get_lock(int lock_type, const MDSCacheObjectInfo &info);
void nudge_log(SimpleLock *lock);
-protected:
- void send_lock_message(SimpleLock *lock, int msg);
- void send_lock_message(SimpleLock *lock, int msg, const bufferlist &data);
-
- // -- locks --
- void _drop_locks(MutationImpl *mut, std::set<CInode*> *pneed_issue, bool drop_rdlocks);
-public:
void include_snap_rdlocks(CInode *in, MutationImpl::LockOpVec& lov);
void include_snap_rdlocks_wlayout(CInode *in, MutationImpl::LockOpVec& lov,
file_layout_t **layout);
void xlock_export(const MutationImpl::lock_iterator& it, MutationImpl *mut);
void xlock_import(SimpleLock *lock);
-
- // simple
-public:
void try_simple_eval(SimpleLock *lock);
bool simple_rdlock_try(SimpleLock *lock, MDSContext *con);
-protected:
- void simple_eval(SimpleLock *lock, bool *need_issue);
- void handle_simple_lock(SimpleLock *lock, const cref_t<MLock> &m);
-public:
bool simple_sync(SimpleLock *lock, bool *need_issue=0);
-protected:
- void simple_lock(SimpleLock *lock, bool *need_issue=0);
- void simple_excl(SimpleLock *lock, bool *need_issue=0);
- void simple_xlock(SimpleLock *lock);
-
- // scatter
-public:
+ // scatter
void scatter_eval(ScatterLock *lock, bool *need_issue); // public for MDCache::adjust_subtree_auth()
void scatter_tick();
void scatter_nudge(ScatterLock *lock, MDSContext *c, bool forcelockchange=false);
-protected:
- void handle_scatter_lock(ScatterLock *lock, const cref_t<MLock> &m);
- bool scatter_scatter_fastpath(ScatterLock *lock);
- void scatter_scatter(ScatterLock *lock, bool nowait=false);
- void scatter_tempsync(ScatterLock *lock, bool *need_issue=0);
-
- void scatter_writebehind(ScatterLock *lock);
-
- void scatter_writebehind_finish(ScatterLock *lock, MutationRef& mut);
-
- xlist<ScatterLock*> updated_scatterlocks;
-public:
void mark_updated_scatterlock(ScatterLock *lock);
-
void handle_reqrdlock(SimpleLock *lock, const cref_t<MLock> &m);
-
-
// caps
// when to defer processing client cap release or writeback due to being
std::vector<client_t> get_late_revoking_clients(double timeout) const;
-private:
- bool any_late_revoking_caps(xlist<Capability*> const &revoking, double timeout) const;
-
-protected:
- bool _need_flush_mdlog(CInode *in, int wanted_caps);
- void adjust_cap_wanted(Capability *cap, int wanted, int issue_seq);
- void handle_client_caps(const cref_t<MClientCaps> &m);
- void _update_cap_fields(CInode *in, int dirty, const cref_t<MClientCaps> &m, CInode::mempool_inode *pi);
- void _do_snap_update(CInode *in, snapid_t snap, int dirty, snapid_t follows, client_t client, const cref_t<MClientCaps> &m, const ref_t<MClientCaps> &ack);
- void _do_null_snapflush(CInode *head_in, client_t client, snapid_t last=CEPH_NOSNAP);
- bool _do_cap_update(CInode *in, Capability *cap, int dirty, snapid_t follows, const cref_t<MClientCaps> &m,
- const ref_t<MClientCaps> &ack, bool *need_flush=NULL);
- void handle_client_cap_release(const cref_t<MClientCapRelease> &m);
- void _do_cap_release(client_t client, inodeno_t ino, uint64_t cap_id, ceph_seq_t mseq, ceph_seq_t seq);
- void caps_tick();
-
- // Maintain a global list to quickly find if any caps are late revoking
- xlist<Capability*> revoking_caps;
- // Maintain a per-client list to find clients responsible for late ones quickly
- std::map<client_t, xlist<Capability*> > revoking_caps_by_client;
-
- elist<CInode*> need_snapflush_inodes;
-public:
void snapflush_nudge(CInode *in);
void mark_need_snapflush_inode(CInode *in);
bool is_revoking_any_caps_from(client_t client);
// local
-public:
void local_wrlock_grab(LocalLock *lock, MutationRef& mut);
-protected:
- bool local_wrlock_start(LocalLock *lock, MDRequestRef& mut);
- void local_wrlock_finish(const MutationImpl::lock_iterator& it, MutationImpl *mut);
- bool local_xlock_start(LocalLock *lock, MDRequestRef& mut);
- void local_xlock_finish(const MutationImpl::lock_iterator& it, MutationImpl *mut);
-
// file
-public:
void file_eval(ScatterLock *lock, bool *need_issue);
-protected:
- void handle_file_lock(ScatterLock *lock, const cref_t<MLock> &m);
- void scatter_mix(ScatterLock *lock, bool *need_issue=0);
- void file_excl(ScatterLock *lock, bool *need_issue=0);
- void file_xsyn(SimpleLock *lock, bool *need_issue=0);
-
-public:
void file_recover(ScatterLock *lock);
-private:
- xlist<ScatterLock*> updated_filelocks;
-public:
void mark_updated_Filelock(ScatterLock *lock);
// -- file i/o --
-public:
version_t issue_file_data_version(CInode *in);
Capability* issue_new_caps(CInode *in, int mode, Session *session, SnapRealm *conrealm, bool is_replay);
int issue_caps(CInode *in, Capability *only_cap=0);
void resume_stale_caps(Session *session);
void remove_stale_leases(Session *session);
-public:
void request_inode_file_caps(CInode *in);
-protected:
- void handle_inode_file_caps(const cref_t<MInodeFileCaps> &m);
- void file_update_finish(CInode *in, MutationRef& mut, unsigned flags,
- client_t client, const ref_t<MClientCaps> &ack);
-private:
- uint64_t calc_new_max_size(CInode::mempool_inode *pi, uint64_t size);
-public:
void calc_new_client_ranges(CInode *in, uint64_t size, bool update,
CInode::mempool_inode::client_range_map* new_ranges,
bool *max_increased);
utime_t mtime=utime_t());
void share_inode_max_size(CInode *in, Capability *only_cap=0);
+ // -- client leases --
+ void handle_client_lease(const cref_t<MClientLease> &m);
+
+ void issue_client_lease(CDentry *dn, client_t client, bufferlist &bl, utime_t now, Session *session);
+ void revoke_client_leases(SimpleLock *lock);
+ static void encode_lease(bufferlist& bl, const session_info_t& info, const LeaseStat& ls);
+
+protected:
+ void send_lock_message(SimpleLock *lock, int msg);
+ void send_lock_message(SimpleLock *lock, int msg, const bufferlist &data);
+
+ // -- locks --
+ void _drop_locks(MutationImpl *mut, std::set<CInode*> *pneed_issue, bool drop_rdlocks);
+
+ void simple_eval(SimpleLock *lock, bool *need_issue);
+ void handle_simple_lock(SimpleLock *lock, const cref_t<MLock> &m);
+
+ void simple_lock(SimpleLock *lock, bool *need_issue=0);
+ void simple_excl(SimpleLock *lock, bool *need_issue=0);
+ void simple_xlock(SimpleLock *lock);
+
+ void handle_scatter_lock(ScatterLock *lock, const cref_t<MLock> &m);
+ bool scatter_scatter_fastpath(ScatterLock *lock);
+ void scatter_scatter(ScatterLock *lock, bool nowait=false);
+ void scatter_tempsync(ScatterLock *lock, bool *need_issue=0);
+
+ void scatter_writebehind(ScatterLock *lock);
+
+ void scatter_writebehind_finish(ScatterLock *lock, MutationRef& mut);
+
+ bool _need_flush_mdlog(CInode *in, int wanted_caps);
+ void adjust_cap_wanted(Capability *cap, int wanted, int issue_seq);
+ void handle_client_caps(const cref_t<MClientCaps> &m);
+ void _update_cap_fields(CInode *in, int dirty, const cref_t<MClientCaps> &m, CInode::mempool_inode *pi);
+ void _do_snap_update(CInode *in, snapid_t snap, int dirty, snapid_t follows, client_t client, const cref_t<MClientCaps> &m, const ref_t<MClientCaps> &ack);
+ void _do_null_snapflush(CInode *head_in, client_t client, snapid_t last=CEPH_NOSNAP);
+ bool _do_cap_update(CInode *in, Capability *cap, int dirty, snapid_t follows, const cref_t<MClientCaps> &m,
+ const ref_t<MClientCaps> &ack, bool *need_flush=NULL);
+ void handle_client_cap_release(const cref_t<MClientCapRelease> &m);
+ void _do_cap_release(client_t client, inodeno_t ino, uint64_t cap_id, ceph_seq_t mseq, ceph_seq_t seq);
+ void caps_tick();
+
+ bool local_wrlock_start(LocalLock *lock, MDRequestRef& mut);
+ void local_wrlock_finish(const MutationImpl::lock_iterator& it, MutationImpl *mut);
+ bool local_xlock_start(LocalLock *lock, MDRequestRef& mut);
+ void local_xlock_finish(const MutationImpl::lock_iterator& it, MutationImpl *mut);
+
+ void handle_file_lock(ScatterLock *lock, const cref_t<MLock> &m);
+ void scatter_mix(ScatterLock *lock, bool *need_issue=0);
+ void file_excl(ScatterLock *lock, bool *need_issue=0);
+ void file_xsyn(SimpleLock *lock, bool *need_issue=0);
+
+ void handle_inode_file_caps(const cref_t<MInodeFileCaps> &m);
+
+ void file_update_finish(CInode *in, MutationRef& mut, unsigned flags,
+ client_t client, const ref_t<MClientCaps> &ack);
+
+ xlist<ScatterLock*> updated_scatterlocks;
+
+ // Maintain a global list to quickly find if any caps are late revoking
+ xlist<Capability*> revoking_caps;
+ // Maintain a per-client list to find clients responsible for late ones quickly
+ std::map<client_t, xlist<Capability*> > revoking_caps_by_client;
+
+ elist<CInode*> need_snapflush_inodes;
+
private:
friend class C_MDL_CheckMaxSize;
friend class C_MDL_RequestInodeFileCaps;
friend class LockerContext;
friend class LockerLogContext;
-
- // -- client leases --
-public:
- void handle_client_lease(const cref_t<MClientLease> &m);
+ bool any_late_revoking_caps(xlist<Capability*> const &revoking, double timeout) const;
+ uint64_t calc_new_max_size(CInode::mempool_inode *pi, uint64_t size);
- void issue_client_lease(CDentry *dn, client_t client, bufferlist &bl, utime_t now, Session *session);
- void revoke_client_leases(SimpleLock *lock);
- static void encode_lease(bufferlist& bl, const session_info_t& info, const LeaseStat& ls);
+ MDSRank *mds;
+ MDCache *mdcache;
+ xlist<ScatterLock*> updated_filelocks;
};
-
-
#endif