Skip to content

Commit 5099c4e

Browse files
committed
client: check for bad file handle in ll_preadv_pwritev
Along with some minor adjustments to the code to make use of same int for all the ops. Fixes: https://tracker.ceph.com/issues/64313 Signed-off-by: Dhairya Parmar <[email protected]>
1 parent 5d1255c commit 5099c4e

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/client/Client.cc

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15942,23 +15942,34 @@ int64_t Client::ll_preadv_pwritev(struct Fh *fh, const struct iovec *iov,
1594215942
Context *onfinish, bufferlist *bl,
1594315943
bool do_fsync, bool syncdataonly)
1594415944
{
15945+
int64_t retval = -1;
15946+
1594515947
RWRef_t mref_reader(mount_state, CLIENT_MOUNTING);
1594615948
if (!mref_reader.is_state_satisfied()) {
15947-
int64_t rc = -CEPHFS_ENOTCONN;
15949+
retval = -CEPHFS_ENOTCONN;
1594815950
if (onfinish != nullptr) {
15949-
onfinish->complete(rc);
15951+
onfinish->complete(retval);
1595015952
/* async call should always return zero to caller and allow the
1595115953
caller to wait on callback for the actual errno. */
15952-
rc = 0;
15954+
retval = 0;
15955+
}
15956+
return retval;
15957+
}
15958+
15959+
if(fh == NULL || !_ll_fh_exists(fh)) {
15960+
ldout(cct, 3) << "(fh)" << fh << " is invalid" << dendl;
15961+
retval = -CEPHFS_EBADF;
15962+
if (onfinish != nullptr) {
15963+
onfinish->complete(retval);
15964+
retval = 0;
1595315965
}
15954-
return rc;
15966+
return retval;
1595515967
}
1595615968

1595715969
std::scoped_lock cl(client_lock);
1595815970

15959-
int64_t retval = _preadv_pwritev_locked(fh, iov, iovcnt, offset, write,
15960-
true, onfinish, bl, do_fsync,
15961-
syncdataonly);
15971+
retval = _preadv_pwritev_locked(fh, iov, iovcnt, offset, write, true,
15972+
onfinish, bl, do_fsync, syncdataonly);
1596215973
/* There are two scenarios with each having two cases to handle here
1596315974
1) async io
1596415975
1.a) r == 0:

0 commit comments

Comments
 (0)