From 0df562a8e13e1e655d3d6a8f4005c450c5190a56 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Wed, 9 Nov 2016 09:36:07 -0500 Subject: [PATCH] client: change no_delay flag to a flags field In a later patch, we'll want to have the client set the sync flag in the cap flush, to hint to the MDS that it should process it immediately. We could add a second bool, but let's instead do what the kernel client does which is to have a flags field. With that, the existing no_delay bool becomes CHECK_CAPS_NODELAY. We'll add other flags in subsequent patches. Signed-off-by: Jeff Layton --- src/client/Client.cc | 46 ++++++++++++++++++++++---------------------- src/client/Client.h | 6 +++++- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 3ab101e9f5d99..97de9faafabab 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -3054,7 +3054,7 @@ void Client::put_cap_ref(Inode *in, int cap) ++put_nref; } if (drop) - check_caps(in, false); + check_caps(in, 0); if (put_nref) put_inode(in, put_nref); } @@ -3088,7 +3088,7 @@ int Client::get_caps(Inode *in, int need, int want, int *phave, loff_t endoff) endoff > (loff_t)in->wanted_max_size) { ldout(cct, 10) << "wanted_max_size " << in->wanted_max_size << " -> " << endoff << dendl; in->wanted_max_size = endoff; - check_caps(in, false); + check_caps(in, 0); } if (endoff >= 0 && endoff > (loff_t)in->max_size) { @@ -3293,9 +3293,9 @@ void Client::send_cap(Inode *in, MetaSession *session, Cap *cap, * revoked caps to the MDS as appropriate. * * @param in the inode to check - * @param no_delay whether we should delay sending caps + * @param flags flags to apply to cap check */ -void Client::check_caps(Inode *in, bool no_delay) +void Client::check_caps(Inode *in, unsigned flags) { unsigned wanted = in->caps_wanted(); unsigned used = get_caps_used(in); @@ -3325,7 +3325,7 @@ void Client::check_caps(Inode *in, bool no_delay) << " used " << ccap_string(used) << " issued " << ccap_string(issued) << " revoking " << ccap_string(revoking) - << " no_delay=" << no_delay + << " flags=" << flags << dendl; if (in->snapid != CEPH_NOSNAP) @@ -3341,7 +3341,7 @@ void Client::check_caps(Inode *in, bool no_delay) if (!in->cap_snaps.empty()) flush_snaps(in); - if (no_delay) + if (flags & CHECK_CAPS_NODELAY) in->hold_caps_until = utime_t(); else cap_delay_requeue(in); @@ -3860,7 +3860,7 @@ void Client::add_update_cap(Inode *in, MetaSession *mds_session, uint64_t cap_id if (it->second == cap) continue; if (it->second->implemented & ~it->second->issued & issued) { - check_caps(in, true); + check_caps(in, CHECK_CAPS_NODELAY); break; } } @@ -4121,7 +4121,7 @@ void Client::flush_caps() Inode *in = *p; ++p; delayed_caps.pop_front(); - check_caps(in, true); + check_caps(in, CHECK_CAPS_NODELAY); } // other caps, too @@ -4129,7 +4129,7 @@ void Client::flush_caps() while (!p.end()) { Inode *in = *p; ++p; - check_caps(in, true); + check_caps(in, CHECK_CAPS_NODELAY); } } @@ -4998,7 +4998,7 @@ void Client::handle_cap_grant(MetaSession *session, Inode *in, Cap *cap, MClient } if (check) - check_caps(in, false); + check_caps(in, 0); // wake up waiters if (new_caps) @@ -5873,7 +5873,7 @@ void Client::tick() break; delayed_caps.pop_front(); cap_list.push_back(&in->cap_item); - check_caps(in, true); + check_caps(in, CHECK_CAPS_NODELAY); } trim_cache(true); @@ -8048,7 +8048,7 @@ int Client::_release_fh(Fh *f) if (in->snapid == CEPH_NOSNAP) { if (in->put_open_ref(f->mode)) { _flush(in, new C_Client_FlushComplete(this, in)); - check_caps(in, false); + check_caps(in, 0); } } else { assert(in->snap_cap_refs > 0); @@ -8097,7 +8097,7 @@ int Client::_open(Inode *in, int flags, mode_t mode, Fh **fhp, if ((flags & O_TRUNC) == 0 && in->caps_issued_mask(want)) { // update wanted? - check_caps(in, true); + check_caps(in, CHECK_CAPS_NODELAY); } else { MetaRequest *req = new MetaRequest(CEPH_MDS_OP_OPEN); filepath path; @@ -8133,7 +8133,7 @@ int Client::_renew_caps(Inode *in) int wanted = in->caps_file_wanted(); if (in->is_any_caps() && ((wanted & CEPH_CAP_ANY_WR) == 0 || in->auth_cap)) { - check_caps(in, true); + check_caps(in, CHECK_CAPS_NODELAY); return 0; } @@ -8466,7 +8466,7 @@ done: in->inline_data.clear(); in->inline_version = CEPH_INLINE_NONE; mark_caps_dirty(in, CEPH_CAP_FILE_WR); - check_caps(in, false); + check_caps(in, 0); } else r = uninline_ret; } @@ -8927,11 +8927,11 @@ success: mark_caps_dirty(in, CEPH_CAP_FILE_WR); if (is_quota_bytes_approaching(in, f->actor_perms)) { - check_caps(in, true); + check_caps(in, CHECK_CAPS_NODELAY); } else { if ((in->size << 1) >= in->max_size && (in->reported_size << 1) < in->max_size) - check_caps(in, false); + check_caps(in, 0); } ldout(cct, 7) << "wrote to " << totalwritten+offset << ", extending file size" << dendl; @@ -8958,7 +8958,7 @@ done: in->inline_data.clear(); in->inline_version = CEPH_INLINE_NONE; mark_caps_dirty(in, CEPH_CAP_FILE_WR); - check_caps(in, false); + check_caps(in, 0); } else r = uninline_ret; } @@ -9047,7 +9047,7 @@ int Client::_fsync(Inode *in, bool syncdataonly) } if (!syncdataonly && in->dirty_caps) { - check_caps(in, true); + check_caps(in, CHECK_CAPS_NODELAY); if (in->flushing_caps) flush_tid = last_flush_tid; } else ldout(cct, 10) << "no metadata needs to commit" << dendl; @@ -9718,7 +9718,7 @@ int Client::lazyio_synchronize(int fd, loff_t offset, size_t count) _fsync(f, true); if (_release(in)) - check_caps(in, false); + check_caps(in, 0); return 0; } @@ -12275,11 +12275,11 @@ int Client::_fallocate(Fh *fh, int mode, int64_t offset, int64_t length) mark_caps_dirty(in, CEPH_CAP_FILE_WR); if (is_quota_bytes_approaching(in, fh->actor_perms)) { - check_caps(in, true); + check_caps(in, CHECK_CAPS_NODELAY); } else { if ((in->size << 1) >= in->max_size && (in->reported_size << 1) < in->max_size) - check_caps(in, false); + check_caps(in, 0); } } } @@ -12296,7 +12296,7 @@ int Client::_fallocate(Fh *fh, int mode, int64_t offset, int64_t length) in->inline_data.clear(); in->inline_version = CEPH_INLINE_NONE; mark_caps_dirty(in, CEPH_CAP_FILE_WR); - check_caps(in, false); + check_caps(in, 0); } else r = uninline_ret; } diff --git a/src/client/Client.h b/src/client/Client.h index 38d0cdab4ac02..f9fceb9853b42 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -651,7 +651,11 @@ protected: void send_cap(Inode *in, MetaSession *session, Cap *cap, bool sync, int used, int want, int retain, int flush, ceph_tid_t flush_tid); - void check_caps(Inode *in, bool immediate); + + /* Flags for check_caps() */ +#define CHECK_CAPS_NODELAY (0x1) + + void check_caps(Inode *in, unsigned flags); void get_cap_ref(Inode *in, int cap); void put_cap_ref(Inode *in, int cap); void flush_snaps(Inode *in, bool all_again=false); -- 2.39.5