@@ -15836,6 +15836,10 @@ int Client::ll_read(Fh *fh, loff_t off, loff_t len, bufferlist *bl)
15836
15836
return -CEPHFS_ENOTCONN;
15837
15837
}
15838
15838
15839
+ /* We can't return bytes written larger than INT_MAX, clamp len to that */
15840
+ len = std::min(len, (loff_t)INT_MAX);
15841
+
15842
+ std::scoped_lock lock(client_lock);
15839
15843
if (fh == NULL || !_ll_fh_exists(fh)) {
15840
15844
ldout(cct, 3) << "(fh)" << fh << " is invalid" << dendl;
15841
15845
return -CEPHFS_EBADF;
@@ -15847,10 +15851,6 @@ int Client::ll_read(Fh *fh, loff_t off, loff_t len, bufferlist *bl)
15847
15851
tout(cct) << off << std::endl;
15848
15852
tout(cct) << len << std::endl;
15849
15853
15850
- /* We can't return bytes written larger than INT_MAX, clamp len to that */
15851
- len = std::min(len, (loff_t)INT_MAX);
15852
- std::scoped_lock lock(client_lock);
15853
-
15854
15854
int r = _read(fh, off, len, bl);
15855
15855
ldout(cct, 3) << "ll_read " << fh << " " << off << "~" << len << " = " << r
15856
15856
<< dendl;
@@ -15981,6 +15981,10 @@ int Client::ll_write(Fh *fh, loff_t off, loff_t len, const char *data)
15981
15981
return -CEPHFS_ENOTCONN;
15982
15982
}
15983
15983
15984
+ /* We can't return bytes written larger than INT_MAX, clamp len to that */
15985
+ len = std::min(len, (loff_t)INT_MAX);
15986
+
15987
+ std::scoped_lock lock(client_lock);
15984
15988
if (fh == NULL || !_ll_fh_exists(fh)) {
15985
15989
ldout(cct, 3) << "(fh)" << fh << " is invalid" << dendl;
15986
15990
return -CEPHFS_EBADF;
@@ -15993,10 +15997,6 @@ int Client::ll_write(Fh *fh, loff_t off, loff_t len, const char *data)
15993
15997
tout(cct) << off << std::endl;
15994
15998
tout(cct) << len << std::endl;
15995
15999
15996
- /* We can't return bytes written larger than INT_MAX, clamp len to that */
15997
- len = std::min(len, (loff_t)INT_MAX);
15998
- std::scoped_lock lock(client_lock);
15999
-
16000
16000
int r = _write(fh, off, len, data, NULL, 0);
16001
16001
ldout(cct, 3) << "ll_write " << fh << " " << off << "~" << len << " = " << r
16002
16002
<< dendl;
@@ -16010,12 +16010,11 @@ int64_t Client::ll_writev(struct Fh *fh, const struct iovec *iov, int iovcnt, in
16010
16010
return -CEPHFS_ENOTCONN;
16011
16011
}
16012
16012
16013
+ std::scoped_lock cl(client_lock);
16013
16014
if (fh == NULL || !_ll_fh_exists(fh)) {
16014
16015
ldout(cct, 3) << "(fh)" << fh << " is invalid" << dendl;
16015
16016
return -CEPHFS_EBADF;
16016
16017
}
16017
-
16018
- std::scoped_lock cl(client_lock);
16019
16018
return _preadv_pwritev_locked(fh, iov, iovcnt, off, true, false);
16020
16019
}
16021
16020
@@ -16026,12 +16025,11 @@ int64_t Client::ll_readv(struct Fh *fh, const struct iovec *iov, int iovcnt, int
16026
16025
return -CEPHFS_ENOTCONN;
16027
16026
}
16028
16027
16028
+ std::scoped_lock cl(client_lock);
16029
16029
if (fh == NULL || !_ll_fh_exists(fh)) {
16030
16030
ldout(cct, 3) << "(fh)" << fh << " is invalid" << dendl;
16031
16031
return -CEPHFS_EBADF;
16032
16032
}
16033
-
16034
- std::scoped_lock cl(client_lock);
16035
16033
return _preadv_pwritev_locked(fh, iov, iovcnt, off, false, false);
16036
16034
}
16037
16035
@@ -16054,18 +16052,24 @@ int64_t Client::ll_preadv_pwritev(struct Fh *fh, const struct iovec *iov,
16054
16052
return retval;
16055
16053
}
16056
16054
16055
+ retval = 0;
16056
+ std::unique_lock cl(client_lock);
16057
+
16057
16058
if(fh == NULL || !_ll_fh_exists(fh)) {
16058
16059
ldout(cct, 3) << "(fh)" << fh << " is invalid" << dendl;
16059
16060
retval = -CEPHFS_EBADF;
16061
+ }
16062
+
16063
+ if (retval != 0) {
16060
16064
if (onfinish != nullptr) {
16065
+ cl.unlock();
16061
16066
onfinish->complete(retval);
16067
+ cl.lock();
16062
16068
retval = 0;
16063
16069
}
16064
16070
return retval;
16065
16071
}
16066
16072
16067
- std::scoped_lock cl(client_lock);
16068
-
16069
16073
retval = _preadv_pwritev_locked(fh, iov, iovcnt, offset, write, true,
16070
16074
onfinish, bl, do_fsync, syncdataonly);
16071
16075
/* There are two scenarios with each having two cases to handle here
@@ -16086,9 +16090,9 @@ int64_t Client::ll_preadv_pwritev(struct Fh *fh, const struct iovec *iov,
16086
16090
if (retval < 0) {
16087
16091
if (onfinish != nullptr) {
16088
16092
//async io failed
16089
- client_lock .unlock();
16093
+ cl .unlock();
16090
16094
onfinish->complete(retval);
16091
- client_lock .lock();
16095
+ cl .lock();
16092
16096
/* async call should always return zero to caller and allow the
16093
16097
caller to wait on callback for the actual errno/retval. */
16094
16098
retval = 0;
0 commit comments