mirror of
https://github.com/ceph/ceph
synced 2025-01-20 10:01:45 +00:00
Merge pull request #34421 from ifed01/wip-ifed-kill-buf-in-read
os/bluestore: kill buf param in BlueFS::read Reviewed-by: Adam Kupczyk <akucpzyk@redhat.com>
This commit is contained in:
commit
56852b0b89
@ -1010,7 +1010,7 @@ int BlueFS::_replay(bool noop, bool to_stdout)
|
||||
uint64_t read_pos = pos;
|
||||
bufferlist bl;
|
||||
{
|
||||
int r = _read(log_reader, &log_reader->buf, read_pos, super.block_size,
|
||||
int r = _read(log_reader, read_pos, super.block_size,
|
||||
&bl, NULL);
|
||||
ceph_assert(r == (int)super.block_size);
|
||||
read_pos += r;
|
||||
@ -1063,7 +1063,7 @@ int BlueFS::_replay(bool noop, bool to_stdout)
|
||||
dout(20) << __func__ << " need 0x" << std::hex << more << std::dec
|
||||
<< " more bytes" << dendl;
|
||||
bufferlist t;
|
||||
int r = _read(log_reader, &log_reader->buf, read_pos, more, &t, NULL);
|
||||
int r = _read(log_reader, read_pos, more, &t, NULL);
|
||||
if (r < (int)more) {
|
||||
derr << __func__ << " 0x" << std::hex << pos
|
||||
<< ": stop: len is 0x" << bl.length() + more << std::dec
|
||||
@ -1133,7 +1133,7 @@ int BlueFS::_replay(bool noop, bool to_stdout)
|
||||
uint64_t skip = offset - read_pos;
|
||||
if (skip) {
|
||||
bufferlist junk;
|
||||
int r = _read(log_reader, &log_reader->buf, read_pos, skip, &junk,
|
||||
int r = _read(log_reader, read_pos, skip, &junk,
|
||||
NULL);
|
||||
if (r != (int)skip) {
|
||||
dout(10) << __func__ << " 0x" << std::hex << read_pos
|
||||
@ -1964,12 +1964,13 @@ int BlueFS::_read_random(
|
||||
|
||||
int BlueFS::_read(
|
||||
FileReader *h, ///< [in] read from here
|
||||
FileReaderBuffer *buf, ///< [in] reader state
|
||||
uint64_t off, ///< [in] offset
|
||||
size_t len, ///< [in] this many bytes
|
||||
bufferlist *outbl, ///< [out] optional: reference the result here
|
||||
char *out) ///< [out] optional: or copy it here
|
||||
{
|
||||
FileReaderBuffer *buf = &(h->buf);
|
||||
|
||||
bool prefetch = !outbl && !out;
|
||||
dout(10) << __func__ << " h " << h
|
||||
<< " 0x" << std::hex << off << "~" << len << std::dec
|
||||
|
@ -390,7 +390,6 @@ private:
|
||||
|
||||
int _read(
|
||||
FileReader *h, ///< [in] read from here
|
||||
FileReaderBuffer *buf, ///< [in] reader state
|
||||
uint64_t offset, ///< [in] offset
|
||||
size_t len, ///< [in] this many bytes
|
||||
ceph::buffer::list *outbl, ///< [out] optional: reference the result here
|
||||
@ -559,12 +558,12 @@ public:
|
||||
std::unique_lock l(lock);
|
||||
return _fsync(h, l);
|
||||
}
|
||||
int read(FileReader *h, FileReaderBuffer *buf, uint64_t offset, size_t len,
|
||||
int read(FileReader *h, uint64_t offset, size_t len,
|
||||
ceph::buffer::list *outbl, char *out) {
|
||||
// no need to hold the global lock here; we only touch h and
|
||||
// h->file, and read vs write or delete is already protected (via
|
||||
// atomics and asserts).
|
||||
return _read(h, buf, offset, len, outbl, out);
|
||||
return _read(h, offset, len, outbl, out);
|
||||
}
|
||||
int read_random(FileReader *h, uint64_t offset, size_t len,
|
||||
char *out) {
|
||||
|
@ -47,7 +47,7 @@ class BlueRocksSequentialFile : public rocksdb::SequentialFile {
|
||||
//
|
||||
// REQUIRES: External synchronization
|
||||
rocksdb::Status Read(size_t n, rocksdb::Slice* result, char* scratch) override {
|
||||
int r = fs->read(h, &h->buf, h->buf.pos, n, NULL, scratch);
|
||||
int r = fs->read(h, h->buf.pos, n, NULL, scratch);
|
||||
ceph_assert(r >= 0);
|
||||
*result = rocksdb::Slice(scratch, r);
|
||||
return rocksdb::Status::OK();
|
||||
@ -123,7 +123,7 @@ class BlueRocksRandomAccessFile : public rocksdb::RandomAccessFile {
|
||||
|
||||
// Readahead the file starting from offset by n bytes for caching.
|
||||
rocksdb::Status Prefetch(uint64_t offset, size_t n) override {
|
||||
fs->read(h, &h->buf, offset, n, nullptr, nullptr);
|
||||
fs->read(h, offset, n, nullptr, nullptr);
|
||||
return rocksdb::Status::OK();
|
||||
}
|
||||
|
||||
|
@ -642,7 +642,7 @@ int main(int argc, char **argv)
|
||||
int left = size;
|
||||
while (left) {
|
||||
bufferlist bl;
|
||||
r = fs->read(h, &h->buf, pos, left, &bl, NULL);
|
||||
r = fs->read(h, pos, left, &bl, NULL);
|
||||
if (r <= 0) {
|
||||
cerr << "read " << dir << "/" << file << " from " << pos
|
||||
<< " failed: " << cpp_strerror(r) << std::endl;
|
||||
|
@ -158,8 +158,7 @@ TEST(BlueFS, write_read) {
|
||||
BlueFS::FileReader *h;
|
||||
ASSERT_EQ(0, fs.open_for_read("dir", "file", &h));
|
||||
bufferlist bl;
|
||||
BlueFS::FileReaderBuffer buf(4096);
|
||||
ASSERT_EQ(9, fs.read(h, &buf, 0, 1024, &bl, NULL));
|
||||
ASSERT_EQ(9, fs.read(h, 0, 1024, &bl, NULL));
|
||||
ASSERT_EQ(0, strncmp("foobarbaz", bl.c_str(), 9));
|
||||
delete h;
|
||||
}
|
||||
@ -231,10 +230,9 @@ TEST(BlueFS, very_large_write) {
|
||||
BlueFS::FileReader *h;
|
||||
ASSERT_EQ(0, fs.open_for_read("dir", "bigfile", &h));
|
||||
bufferlist bl;
|
||||
BlueFS::FileReaderBuffer readbuf(10485760);
|
||||
for (unsigned i = 0; i < 3*1024*1048576ull / sizeof(buf); ++i) {
|
||||
bl.clear();
|
||||
fs.read(h, &readbuf, i * sizeof(buf), sizeof(buf), &bl, NULL);
|
||||
fs.read(h, i * sizeof(buf), sizeof(buf), &bl, NULL);
|
||||
int r = memcmp(buf, bl.c_str(), sizeof(buf));
|
||||
if (r) {
|
||||
cerr << "read got mismatch at offset " << i*sizeof(buf) << " r " << r
|
||||
|
Loading…
Reference in New Issue
Block a user