From: Dhairya Parmar Date: Tue, 20 Feb 2024 12:02:45 +0000 (+0530) Subject: client: check for bad file handle in ll_preadv_pwritev X-Git-Tag: testing/wip-root-testing-20240411.174241~108^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=ebdb754d70ba386fd7703413b7d4cacf8d1e1084;p=ceph-ci.git 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 (cherry picked from commit 5099c4ef5841c0f80a9ca1844d254ecce25d269b) --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 6ee5e742b9b..b999726e479 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -15942,23 +15942,34 @@ int64_t Client::ll_preadv_pwritev(struct Fh *fh, const struct iovec *iov, Context *onfinish, bufferlist *bl, bool do_fsync, bool syncdataonly) { + int64_t retval = -1; + RWRef_t mref_reader(mount_state, CLIENT_MOUNTING); if (!mref_reader.is_state_satisfied()) { - int64_t rc = -CEPHFS_ENOTCONN; + retval = -CEPHFS_ENOTCONN; if (onfinish != nullptr) { - onfinish->complete(rc); + onfinish->complete(retval); /* async call should always return zero to caller and allow the caller to wait on callback for the actual errno. */ - rc = 0; + retval = 0; + } + return retval; + } + + if(fh == NULL || !_ll_fh_exists(fh)) { + ldout(cct, 3) << "(fh)" << fh << " is invalid" << dendl; + retval = -CEPHFS_EBADF; + if (onfinish != nullptr) { + onfinish->complete(retval); + retval = 0; } - return rc; + return retval; } std::scoped_lock cl(client_lock); - int64_t retval = _preadv_pwritev_locked(fh, iov, iovcnt, offset, write, - true, onfinish, bl, do_fsync, - syncdataonly); + retval = _preadv_pwritev_locked(fh, iov, iovcnt, offset, write, true, + onfinish, bl, do_fsync, syncdataonly); /* There are two scenarios with each having two cases to handle here 1) async io 1.a) r == 0: