File tree Expand file tree Collapse file tree 3 files changed +22
-8
lines changed
Expand file tree Collapse file tree 3 files changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -3882,7 +3882,9 @@ void Client::put_cap_ref(Inode *in, int cap)
38823882 p.second.dirty_data = 0;
38833883 signal_context_list(in->waitfor_commit);
38843884 ldout(cct, 5) << __func__ << " dropped last FILE_BUFFER ref on " << *in << dendl;
3885- ++put_nref;
3885+ if (!in->is_write_delegated()) {
3886+ ++put_nref;
3887+ }
38863888
38873889 if (!in->cap_snaps.empty()) {
38883890 flush_snaps(in);
@@ -13306,13 +13308,9 @@ int Client::_fsync(Inode *in, bool syncdataonly)
1330613308 ldout(cct, 15) << "got " << r << " from flush writeback" << dendl;
1330713309 } else {
1330813310 // FIXME: this can starve
13309- int nr_refs = 0;
13310- if (in->is_write_delegated()) {
13311- ++nr_refs;
13312- }
13313- while (in->cap_refs[CEPH_CAP_FILE_BUFFER] > nr_refs) {
13311+ while (!in->is_last_cap_ref(CEPH_CAP_FILE_BUFFER)) {
1331413312 ldout(cct, 10) << "ino " << in->ino << " has " << in->cap_refs[CEPH_CAP_FILE_BUFFER]
13315- << " uncommitted (nrefs: " << nr_refs << ") , waiting" << dendl;
13313+ << " uncommitted, waiting" << dendl;
1331613314 wait_on_context_list(in->waitfor_commit);
1331713315 }
1331813316 }
Original file line number Diff line number Diff line change @@ -198,6 +198,20 @@ void Inode::get_cap_ref(int cap)
198198 }
199199}
200200
201+ bool Inode::is_last_cap_ref (int c)
202+ {
203+ if (c != CEPH_CAP_FILE_BUFFER) {
204+ return cap_refs[c] == 0 ;
205+ }
206+
207+ int nref = 0 ;
208+ if (is_write_delegated ()) {
209+ ++nref;
210+ }
211+
212+ return cap_refs[c] == nref;
213+ }
214+
201215int Inode::put_cap_ref (int cap)
202216{
203217 int last = 0 ;
@@ -209,7 +223,8 @@ int Inode::put_cap_ref(int cap)
209223 lderr (client->cct ) << " put_cap_ref " << ccap_string (c) << " went negative on " << *this << dendl;
210224 ceph_assert (cap_refs[c] > 0 );
211225 }
212- if (--cap_refs[c] == 0 )
226+ --cap_refs[c];
227+ if (is_last_cap_ref (c))
213228 last |= c;
214229 // cout << "inode " << *this << " put " << cap_string(c) << " " << (cap_refs[c]+1) << " -> " << cap_refs[c] << std::endl;
215230 }
Original file line number Diff line number Diff line change @@ -343,6 +343,7 @@ struct Inode : RefCountedObject {
343343
344344 void get_cap_ref (int cap);
345345 int put_cap_ref (int cap);
346+ bool is_last_cap_ref (int c);
346347 bool is_any_caps ();
347348 bool cap_is_valid (const Cap &cap) const ;
348349 int caps_issued (int *implemented = 0 ) const ;
You can’t perform that action at this time.
0 commit comments