Skip to content

Commit 9d4ae97

Browse files
committed
client: handle callback completion if the async I/O failed
and remove the context completion code from Client::_preadv_pwritev_locked since this case will indeed be handled in the Client::ll_preadv_pwritev along with all other cases Fixes: https://tracker.ceph.com/issues/63734 Signed-off-by: Dhairya Parmar <[email protected]>
1 parent bbde525 commit 9d4ae97

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

src/client/Client.cc

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11259,11 +11259,6 @@ int64_t Client::_preadv_pwritev_locked(Fh *fh, const struct iovec *iov,
1125911259
onfinish);
1126011260
ldout(cct, 3) << "preadv(" << fh << ", " << offset << ") = " << r << dendl;
1126111261
if (r <= 0) {
11262-
if (r < 0 && onfinish != nullptr) {
11263-
client_lock.unlock();
11264-
onfinish->complete(r);
11265-
client_lock.lock();
11266-
}
1126711262
return r;
1126811263
}
1126911264

@@ -15960,9 +15955,37 @@ int64_t Client::ll_preadv_pwritev(struct Fh *fh, const struct iovec *iov,
1596015955
}
1596115956

1596215957
std::scoped_lock cl(client_lock);
15963-
return _preadv_pwritev_locked(fh, iov, iovcnt, offset, write, true,
15964-
onfinish, bl, do_fsync, syncdataonly);
1596515958

15959+
int64_t retval = _preadv_pwritev_locked(fh, iov, iovcnt, offset, write,
15960+
true, onfinish, bl, do_fsync,
15961+
syncdataonly);
15962+
/* There are two scenarios with each having two cases to handle here
15963+
1) async io
15964+
1.a) r == 0:
15965+
async call in progress, the context will be automatically invoked,
15966+
so just return the retval (i.e. zero).
15967+
1.b) r < 0:
15968+
There was an error; no context completion should've took place so
15969+
complete the context with retval followed by returning zero to the
15970+
caller.
15971+
2) sync io
15972+
2.a) r >= 0:
15973+
sync call success; return the no. of bytes read/written.
15974+
2.b) r < 0:
15975+
sync call failed; return the errno. */
15976+
15977+
if (retval < 0) {
15978+
if (onfinish != nullptr) {
15979+
//async io failed
15980+
client_lock.unlock();
15981+
onfinish->complete(retval);
15982+
client_lock.lock();
15983+
/* async call should always return zero to caller and allow the
15984+
caller to wait on callback for the actual errno/retval. */
15985+
retval = 0;
15986+
}
15987+
}
15988+
return retval;
1596615989
}
1596715990

1596815991
int Client::ll_flush(Fh *fh)

0 commit comments

Comments
 (0)