Skip to content

Commit ee86479

Browse files
committed
client: signal waitfor_commit waiters for write delegation enabled inode
Fixes: http://tracker.ceph.com/issues/73624 Signed-off-by: Venky Shankar <[email protected]> Tested-by: Suhas Athani <[email protected]>
1 parent 8534d10 commit ee86479

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

src/client/Client.cc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3797,7 +3797,9 @@ void Client::put_cap_ref(Inode *in, int cap)
37973797
p.second.dirty_data = 0;
37983798
signal_context_list(in->waitfor_commit);
37993799
ldout(cct, 5) << __func__ << " dropped last FILE_BUFFER ref on " << *in << dendl;
3800-
++put_nref;
3800+
if (!in->is_write_delegated()) {
3801+
++put_nref;
3802+
}
38013803

38023804
if (!in->cap_snaps.empty()) {
38033805
flush_snaps(in);
@@ -12456,13 +12458,9 @@ int Client::_fsync(Inode *in, bool syncdataonly)
1245612458
ldout(cct, 15) << "got " << r << " from flush writeback" << dendl;
1245712459
} else {
1245812460
// FIXME: this can starve
12459-
int nr_refs = 0;
12460-
if (in->is_write_delegated()) {
12461-
++nr_refs;
12462-
}
12463-
while (in->cap_refs[CEPH_CAP_FILE_BUFFER] > nr_refs) {
12461+
while (!in->is_last_cap_ref(CEPH_CAP_FILE_BUFFER)) {
1246412462
ldout(cct, 10) << "ino " << in->ino << " has " << in->cap_refs[CEPH_CAP_FILE_BUFFER]
12465-
<< " uncommitted (nrefs: " << nr_refs << "), waiting" << dendl;
12463+
<< " uncommitted, waiting" << dendl;
1246612464
wait_on_context_list(in->waitfor_commit);
1246712465
}
1246812466
}

src/client/Inode.cc

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff 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+
201215
int 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
}

src/client/Inode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ struct Inode : RefCountedObject {
316316

317317
void get_cap_ref(int cap);
318318
int put_cap_ref(int cap);
319+
bool is_last_cap_ref(int c);
319320
bool is_any_caps();
320321
bool cap_is_valid(const Cap &cap) const;
321322
int caps_issued(int *implemented = 0) const;

0 commit comments

Comments
 (0)