From 5f43310150d338d592769e491350f51d8c92cecc Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 1 Jul 2009 11:39:59 -0700 Subject: [PATCH] uclient: support mds recall_state Trim old caps. Still need to make it an LRU. --- src/TODO | 3 +++ src/client/Client.cc | 33 +++++++++++++++++++++++++++++++-- src/client/Client.h | 1 + src/messages/MClientSession.h | 2 ++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/TODO b/src/TODO index a0aa9bff7c2de..f08cd20cb4a68 100644 --- a/src/TODO +++ b/src/TODO @@ -136,12 +136,15 @@ osd - preserve pg logs on disk for longer period - make scrub interruptible - salvage some way to allow both RMW and DELAYED mode ops? + - make the mode per-pg? then at least per-pool access patterns will behave. - optionally separate osd interfaces (ips) for clients and osds (replication, peering, etc.) - pg repair - pg split should be a work queue - optimize remove wrt recovery pushes? userspace client +- make session cap list an LRU + - make caps_issued_mask, touch_cap helpers to || kclient - clean up client mds session vs mdsmap behavior? - stop using mds's inode_t? - fix readdir vs fragment race by keeping a separate frag pos, and ignoring dentries below it diff --git a/src/client/Client.cc b/src/client/Client.cc index 1b47d7f0f2d90..a536df21787ee 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -903,6 +903,11 @@ void Client::handle_client_session(MClientSession *m) mds_sessions[from].was_stale = true; renew_caps(from); break; + + case CEPH_SESSION_RECALL_STATE: + trim_caps(from, m->get_max_caps()); + break; + default: assert(0); } @@ -1801,12 +1806,36 @@ void Client::remove_all_caps(Inode *in) remove_cap(in, in->caps.begin()->first); } -void Client::remove_session_caps(int mds_num) { - MDSSession* mds = &mds_sessions[mds_num]; +void Client::remove_session_caps(int mds_num) +{ + MDSSession *mds = &mds_sessions[mds_num]; while (mds->caps.size()) remove_cap((*mds->caps.begin())->inode, mds_num); } +void Client::trim_caps(int mds, int max) +{ + dout(10) << "trim_caps mds" << mds << " max" << max << dendl; + MDSSession *s = &mds_sessions[mds]; + + int trimmed = 0; + xlist::iterator p = s->caps.begin(); + while (s->caps.size() > max && !p.end()) { + InodeCap *cap = *p; + ++p; + Inode *in = cap->inode; + if (in->caps_used() || + in->caps_dirty()) { + dout(20) << " keeping cap on " << *in << " used " << ccap_string(in->caps_used()) + << " dirty " << ccap_string(in->caps_dirty()) << dendl; + continue; + } + dout(20) << " removing unused cap on " << *in << dendl; + remove_cap(in, mds); + trimmed++; + } +} + void Client::mark_caps_dirty(Inode *in, int caps) { dout(10) << "mark_caps_dirty " << *in << " " << ccap_string(in->dirty_caps) << " -> " diff --git a/src/client/Client.h b/src/client/Client.h index a0aaae4555170..f0062b3a0e5a5 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -866,6 +866,7 @@ protected: void remove_cap(Inode *in, int mds); void remove_all_caps(Inode *in); void remove_session_caps(int mds_num); + void trim_caps(int mds, int max); void mark_caps_dirty(Inode *in, int caps); void maybe_update_snaprealm(SnapRealm *realm, snapid_t snap_created, snapid_t snap_highwater, diff --git a/src/messages/MClientSession.h b/src/messages/MClientSession.h index c823f0f0177e4..e625beb6079d3 100644 --- a/src/messages/MClientSession.h +++ b/src/messages/MClientSession.h @@ -24,6 +24,8 @@ public: int get_op() { return head.op; } version_t get_seq() { return head.seq; } utime_t get_stamp() { return utime_t(head.stamp); } + int get_max_caps() { return head.max_caps; } + int get_max_leases() { return head.max_leases; } MClientSession() : Message(CEPH_MSG_CLIENT_SESSION) { } MClientSession(int o, version_t s=0) : -- 2.39.5