Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client: simplify remove_cap interface #12161

Merged
merged 2 commits into from
Jan 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 9 additions & 18 deletions src/client/Client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3858,7 +3858,7 @@ void Client::add_update_cap(Inode *in, MetaSession *mds_session, uint64_t cap_id
signal_cond_list(in->waitfor_caps);
}

Cap* Client::remove_cap(Cap *cap, bool queue_release)
void Client::remove_cap(Cap *cap, bool queue_release)
{
Inode *in = cap->inode;
MetaSession *session = cap->session;
Expand All @@ -3885,21 +3885,16 @@ Cap* Client::remove_cap(Cap *cap, bool queue_release)
assert(in->caps.count(mds));
in->caps.erase(mds);

if (cap == session->s_cap_iterator) {
cap->inode = NULL;
} else {
cap->cap_item.remove_myself();
delete cap;
cap = nullptr;
}
cap->cap_item.remove_myself();
delete cap;
cap = nullptr;

if (!in->is_any_caps()) {
ldout(cct, 15) << "remove_cap last one, closing snaprealm " << in->snaprealm << dendl;
in->snaprealm_item.remove_myself();
put_snap_realm(in->snaprealm);
in->snaprealm = 0;
}
return cap;
}

void Client::remove_all_caps(Inode *in)
Expand Down Expand Up @@ -3987,16 +3982,19 @@ void Client::trim_caps(MetaSession *s, int max)
xlist<Cap*>::iterator p = s->caps.begin();
while ((caps_size - trimmed) > max && !p.end()) {
Cap *cap = *p;
s->s_cap_iterator = cap;
Inode *in = cap->inode;

// Increment p early because it will be invalidated if cap
// is deleted inside remove_cap
++p;

if (in->caps.size() > 1 && cap != in->auth_cap) {
int mine = cap->issued | cap->implemented;
int oissued = in->auth_cap ? in->auth_cap->issued : 0;
// disposable non-auth cap
if (!(get_caps_used(in) & ~oissued & mine)) {
ldout(cct, 20) << " removing unused, unneeded non-auth cap on " << *in << dendl;
cap = remove_cap(cap, true);
remove_cap(cap, true);
trimmed++;
}
} else {
Expand Down Expand Up @@ -4025,14 +4023,7 @@ void Client::trim_caps(MetaSession *s, int max)
trimmed++;
}
}

++p;
if (cap && !cap->inode) {
cap->cap_item.remove_myself();
delete cap;
}
}
s->s_cap_iterator = NULL;

if (s->caps.size() > max)
_invalidate_kernel_dcache();
Expand Down
2 changes: 1 addition & 1 deletion src/client/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ class Client : public Dispatcher, public md_config_obs_t {
void add_update_cap(Inode *in, MetaSession *session, uint64_t cap_id,
unsigned issued, unsigned seq, unsigned mseq, inodeno_t realm,
int flags, const UserPerm& perms);
Cap* remove_cap(Cap *cap, bool queue_release);
void remove_cap(Cap *cap, bool queue_release);
void remove_all_caps(Inode *in);
void remove_session_caps(MetaSession *session);
void mark_caps_dirty(Inode *in, int caps);
Expand Down
4 changes: 1 addition & 3 deletions src/client/MetaSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,13 @@ struct MetaSession {
std::set<ceph_tid_t> flushing_caps_tids;
std::set<Inode*> early_flushing_caps;

Cap *s_cap_iterator;

MClientCapRelease *release;

MetaSession()
: mds_num(-1), con(NULL),
seq(0), cap_gen(0), cap_renew_seq(0), num_caps(0),
state(STATE_NEW), mds_state(0), readonly(false),
s_cap_iterator(NULL), release(NULL)
release(NULL)
{}
~MetaSession();

Expand Down